Create.E=function(G)return{__eventname=G}end DamageValues={BaseDamage=0,SlashDamage=17}Damage=DamageValues.BaseDamage BaseUrl="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"BasePart=Instance.new("\080\097\114\116")BasePart.Shape=Enum.PartType.Block BasePart.Material=Enum.Material.Plastic BasePart.TopSurface=Enum.SurfaceType.Smooth BasePart.BottomSurface=Enum.SurfaceType.Smooth BasePart.FormFactor=Enum.FormFactor.Custom BasePart.Size=Vector3.new(.2,.2,.2)BasePart.CanCollide=true BasePart.Locked=true BasePart.Anchored=false Animations={LeftSlash={Animation=Tool:WaitForChild("\076\101\102\116\083\108\097\115\104"),FadeTime=nil;Weight=nil,Speed=1.5;Duration=.5};RightSlash={Animation=Tool:WaitForChild("\082\105\103\104\116\083\108\097\115\104");FadeTime=nil,Weight=nil;Speed=1.5,Duration=.5};SideSwipe={Animation=Tool:WaitForChild("\083\105\100\101\083\119\105\112\101"),FadeTime=nil,Weight=nil,Speed=.8;Duration=.5};R15LeftSlash={Animation=Tool:WaitForChild("\082\049\053\076\101\102\116\083\108\097\115\104"),FadeTime=nil;Weight=nil,Speed=1.5;Duration=.5};R15RightSlash={Animation=Tool:WaitForChild("\082\049\053\082\105\103\104\116\083\108\097\115\104"),FadeTime=nil,Weight=nil,Speed=1.5;Duration=.5};R15SideSwipe={Animation=Tool:WaitForChild("\082\049\053\083\105\100\101\083\119\105\112\101");FadeTime=nil,Weight=nil,Speed=.8,Duration=.5}}Sounds={Unsheath=Handle:WaitForChild("\085\110\115\104\101\097\116\104");Slash=Handle:WaitForChild("\083\108\097\115\104"),Lunge=Handle:WaitForChild("\076\117\110\103\101")}LastExplode=0 ToolEquipped=false ServerControl=Tool:FindFirstChild("\083\101\114\118\101\114\067\111\110\116\114\111\108")or(Create("\082\101\109\111\116\101\070\117\110\099\116\105\111\110"))({Name="\083\101\114\118\101\114\067\111\110\116\114\111\108",Parent=Tool})ClientControl=Tool:FindFirstChild("\067\108\105\101\110\116\067\111\110\116\114\111\108")or(Create("\082\101\109\111\116\101\070\117\110\099\116\105\111\110"))({Name="\067\108\105\101\110\116\067\111\110\116\114\111\108";Parent=Tool})Handle.Transparency=0 Tool.Enabled=true function IsTeamMate(G,f)return G and(f and(not G.Neutral and(not f.Neutral and G.TeamColor==f.TeamColor)))end function TagHumanoid(G,f)local v=(Create("\079\098\106\101\099\116\086\097\108\117\101"))({Name="\099\114\101\097\116\111\114";Value=f})Debris:AddItem(v,2)v.Parent=G end function UntagHumanoid(G)for G,f in pairs(G:GetChildren())do if f:IsA("\079\098\106\101\099\116\086\097\108\117\101")and f.Name=="\099\114\101\097\116\111\114"then f:Destroy()end end end function CheckTableForInstance(G,f)for G,v in pairs(G)do if v==f then return true end end return false end function DealDamage(G,f)if not CheckIfAlive()or not G then return end local v=f or 0 local e=G:FindFirstChild("\072\117\109\097\110\111\105\100")local z=G:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if not z then z=G:FindFirstChild("\084\111\114\115\111")end if not e or e.Health==0 or not z then return end UntagHumanoid(e)TagHumanoid(e,Player)e:TakeDamage(v)end function CheckIfAlive()return(Character and(Character.Parent and(Humanoid and(Humanoid.Parent and Humanoid.Health>0))))and true or false end function Blow(G)local f local v=false f=G.Touched:connect(function(G)if not G or not G.Parent or not CheckIfAlive()or not ToolEquipped or v then return end local f=Character:FindFirstChild("\082\105\103\104\116 \065\114\109")or Character:FindFirstChild("\082\105\103\104\116\072\097\110\100")if not f then return end local e=f:FindFirstChild("\082\105\103\104\116\071\114\105\112")if not e or e.Part0~=Handle and e.Part1~=Handle then return end local z=G.Parent if z==Character then return end local j=z:FindFirstChild("\072\117\109\097\110\111\105\100")local r=z:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")or z:FindFirstChild("\084\111\114\115\111")if not j or j.Health==0 or not r then return end local b=Players:GetPlayerFromCharacter(z)if b and(b==Player or IsTeamMate(Player,b))then return end v=true local Y=Damage DealDamage(z,Y)local o=tick()print(o-LastExplode)if math.random()<=.05 and o-LastExplode>=5 then LastExplode=o local G=(Create("\069\120\112\108\111\115\105\111\110"))({Name="\069\120\112\108\111\115\105\111\110";Position=Handle.Position,ExplosionType=Enum.ExplosionType.NoCraters;DestroyJointRadiusPercent=0,BlastPressure=0,BlastRadius=5,Visible=true})local f={}G.Hit:connect(function(G)if not G or not G.Parent then return end local v=G.Parent local e=v:FindFirstChild("\072\117\109\097\110\111\105\100")if not e or e.Health==0 then return end if CheckTableForInstance(f,v)then return end local z=Players:GetPlayerFromCharacter(v)if z and(z~=Player and IsTeamMate(Player,z))then return end table.insert(f,v)UntagHumanoid(e)if z~=Player then TagHumanoid(e,Player)end e:TakeDamage(100/(z==Player and 2 or 1))end)G.Parent=game:GetService("\087\111\114\107\115\112\097\099\101")end wait(.05)v=false end)end function Attack()Damage=DamageValues.SlashDamage Sounds.Slash:Play()local G=Humanoid.RigType==Enum.HumanoidRigType.R6 and{Animations.LeftSlash,Animations.RightSlash;Animations.SideSwipe}or Humanoid.RigType==Enum.HumanoidRigType.R15 and{Animations.R15LeftSlash;Animations.R15SideSwipe}local f=G[math.random(1,#G)]Spawn(function()InvokeClient("\080\108\097\121\065\110\105\109\097\116\105\111\110",f)end)wait(f.Duration)end function Activated()if not Tool.Enabled or not ToolEquipped or not CheckIfAlive()then return end Tool.Enabled=false Attack()Damage=DamageValues.BaseDamage Tool.Enabled=true end function CheckIfAlive()return(Player and(Player.Parent and(Character and(Character.Parent and(Humanoid and(Humanoid.Parent and(Humanoid.Health>0 and(RootPart and RootPart.Parent))))))))and true or false end function Equipped()Character=Tool.Parent Player=Players:GetPlayerFromCharacter(Character)Humanoid=Character:FindFirstChild("\072\117\109\097\110\111\105\100")RootPart=Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if not CheckIfAlive()then return end Sounds.Unsheath:Play()ToolEquipped=true end function Unequipped()Humanoid.WalkSpeed=16 ToolEquipped=false end function OnServerInvoke(G,f,v)if G~=Player or not ToolEquipped or not v or not CheckIfAlive()then return end end function InvokeClient(G,f)local v=nil pcall(function()v=ClientControl:InvokeClient(Player,G,f)end)return v end ServerControl.OnServerInvoke=OnServerInvoke Tool.Activated:connect(Activated)Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)Blow(Handle)

Create.E = function(eventName)
	return {__eventname = eventName}
end


DamageValues = {
	BaseDamage = 0,
	SlashDamage = 17,
}

Damage = DamageValues.BaseDamage

BaseUrl = "http://www.roblox.com/asset/?id="

BasePart = Instance.new("Part")
BasePart.Shape = Enum.PartType.Block
BasePart.Material = Enum.Material.Plastic
BasePart.TopSurface = Enum.SurfaceType.Smooth
BasePart.BottomSurface = Enum.SurfaceType.Smooth
BasePart.FormFactor = Enum.FormFactor.Custom
BasePart.Size = Vector3.new(0.2, 0.2, 0.2)
BasePart.CanCollide = true
BasePart.Locked = true
BasePart.Anchored = false

Animations = {
	LeftSlash = {Animation = Tool:WaitForChild("LeftSlash"), FadeTime = nil, Weight = nil, Speed = 1.5, Duration = 0.5},
	RightSlash = {Animation = Tool:WaitForChild("RightSlash"), FadeTime = nil, Weight = nil, Speed = 1.5, Duration = 0.5},
	SideSwipe = {Animation = Tool:WaitForChild("SideSwipe"), FadeTime = nil, Weight = nil, Speed = 0.8, Duration = 0.5},
	R15LeftSlash = {Animation = Tool:WaitForChild("R15LeftSlash"), FadeTime = nil, Weight = nil, Speed = 1.5, Duration = 0.5},
	R15RightSlash = {Animation = Tool:WaitForChild("R15RightSlash"), FadeTime = nil, Weight = nil, Speed = 1.5, Duration = 0.5},
	R15SideSwipe = {Animation = Tool:WaitForChild("R15SideSwipe"), FadeTime = nil, Weight = nil, Speed = 0.8, Duration = 0.5},

}

Sounds = {
	Unsheath = Handle:WaitForChild("Unsheath"),
	Slash = Handle:WaitForChild("Slash"),
	Lunge = Handle:WaitForChild("Lunge"),
}

LastExplode = 0
ToolEquipped = false

ServerControl = (Tool:FindFirstChild("ServerControl") or Create("RemoteFunction"){
	Name = "ServerControl",
	Parent = Tool,
})

ClientControl = (Tool:FindFirstChild("ClientControl") or Create("RemoteFunction"){
	Name = "ClientControl",
	Parent = Tool,
})

Handle.Transparency = 0
Tool.Enabled = true

function IsTeamMate(Player1, Player2)
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end

function TagHumanoid(humanoid, player)
	local Creator_Tag = Create("ObjectValue"){
		Name = "creator",
		Value = player,
	}
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

function CheckTableForInstance(Table, Instance)
	for i, v in pairs(Table) do
		if v == Instance then
			return true
		end
	end
	return false
end

function DealDamage(character, damage)
	if not CheckIfAlive() or not character then
		return
	end
	local damage = (damage or 0)
	local humanoid = character:FindFirstChild("Humanoid")
	local rootpart = character:FindFirstChild("HumanoidRootPart")
	if not rootpart then
		rootpart = character:FindFirstChild("Torso")
	end
	if not humanoid or humanoid.Health == 0 or not rootpart then
		return
	end
	UntagHumanoid(humanoid)
	TagHumanoid(humanoid, Player)
	humanoid:TakeDamage(damage)
end

function CheckIfAlive()
	return (((Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0) and true) or false)
end

function Blow(Part)
	local PartTouched
	local HitDelay = false
	PartTouched = Part.Touched:connect(function(Hit)
		if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped or HitDelay then
			return
		end
		local RightArm = (Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand"))
		if not RightArm then
			return
		end
		local RightGrip = RightArm:FindFirstChild("RightGrip")
		if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
			return
		end
		local character = Hit.Parent
		if character == Character then
			return
		end
		local humanoid = character:FindFirstChild("Humanoid")
		local rootpart = (character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso"))
		if not humanoid or humanoid.Health == 0 or not rootpart then
			return
		end
		local player = Players:GetPlayerFromCharacter(character)
		if player and (player == Player or IsTeamMate(Player, player)) then
			return
		end
		HitDelay = true
		local TotalDamage = Damage
		DealDamage(character, TotalDamage)
		local Now = tick()
		print((Now - LastExplode))
		if (math.random() <= 0.05) and (Now - LastExplode) >= 5 then
			LastExplode = Now
			local Explosion = Create("Explosion"){
				Name = "Explosion",
				Position = Handle.Position,
				ExplosionType = Enum.ExplosionType.NoCraters,
				DestroyJointRadiusPercent = 0,
				BlastPressure = 0,
				BlastRadius = 5,
				Visible = true,
			}
			local PlayersHit = {}
			Explosion.Hit:connect(function(Hit)
				if not Hit or not Hit.Parent then
					return
				end
				local character = Hit.Parent
				local humanoid = character:FindFirstChild("Humanoid")
				if not humanoid or humanoid.Health == 0 then
					return
				end
				if CheckTableForInstance(PlayersHit, character) then
					return
				end
				local player = Players:GetPlayerFromCharacter(character)
				if player and player ~= Player and IsTeamMate(Player, player) then --don't damage teammates but damage
					return
				end
				table.insert(PlayersHit, character)
				UntagHumanoid(humanoid)
				if player ~= Player then
					TagHumanoid(humanoid, Player)
				end
				humanoid:TakeDamage(100 / ((player == Player and 2) or 1))
			end)
			Explosion.Parent = game:GetService("Workspace")
		end
		wait(0.05)
		HitDelay = false
	end)
end

function Attack()
	Damage = DamageValues.SlashDamage
	Sounds.Slash:Play()
	--[[local Anim = Create("StringValue"){
		Name = "toolanim",
		Value = "Slash",
	}
	Debris:AddItem(Anim, 2)
	Anim.Parent = Tool]]
	local SwingAnimations = ((Humanoid.RigType == Enum.HumanoidRigType.R6 and {Animations.LeftSlash, Animations.RightSlash, Animations.SideSwipe})
		or (Humanoid.RigType == Enum.HumanoidRigType.R15 and {Animations.R15LeftSlash, --[[Animations.R15RightSlash,]] Animations.R15SideSwipe}))
	local Animation = SwingAnimations[math.random(1, #SwingAnimations)]
	Spawn(function()
		InvokeClient("PlayAnimation", Animation)
	end)
	wait(Animation.Duration)
end

function Activated()
	if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
		return
	end
	Tool.Enabled = false
	Attack()
	Damage = DamageValues.BaseDamage
	Tool.Enabled = true
end

function CheckIfAlive()
	return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and RootPart and RootPart.Parent) and true) or false)
end

function Equipped()
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	RootPart = Character:FindFirstChild("HumanoidRootPart")
	if not CheckIfAlive() then
		return
	end
	Sounds.Unsheath:Play()
	ToolEquipped = true
end

function Unequipped()
	Humanoid.WalkSpeed = 16
	ToolEquipped = false
end

function OnServerInvoke(player, mode, value)
	if player ~= Player or not ToolEquipped or not value or not CheckIfAlive() then
		return
	end
end

function InvokeClient(Mode, Value)
	local ClientReturn = nil
	pcall(function()
		ClientReturn = ClientControl:InvokeClient(Player, Mode, Value)
	end)
	return ClientReturn
end

ServerControl.OnServerInvoke = OnServerInvoke

Tool.Activated:connect(Activated)
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)

Blow(Handle)
