Tool=script.Parent Handle=Tool:WaitForChild("\072\097\110\100\108\101")Players=game:GetService("\080\108\097\121\101\114\115")Debris=game:GetService("\068\101\098\114\105\115")RunService=game:GetService("\082\117\110\083\101\114\118\105\099\101")RbxUtility=LoadLibrary("\082\098\120\085\116\105\108\105\116\121")Create=RbxUtility.Create DamageValues={BaseDamage=10,SlashDamage=20}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 Rate=.016666666666667 AnimationsBin=Tool:WaitForChild("\065\110\105\109\097\116\105\111\110\115")R6Anims=AnimationsBin:WaitForChild("\082\054")R15Anims=AnimationsBin:WaitForChild("\082\049\053")Animations={R6LeftSlash={Animation=R6Anims:WaitForChild("\076\101\102\116\083\108\097\115\104");FadeTime=nil;Weight=nil;Speed=1.5,Duration=.5},R6RightSlash={Animation=R6Anims:WaitForChild("\082\105\103\104\116\083\108\097\115\104"),FadeTime=nil,Weight=nil,Speed=1.5;Duration=.5};R6SideSwipe={Animation=R6Anims:WaitForChild("\083\105\100\101\083\119\105\112\101");FadeTime=nil,Weight=nil,Speed=.8;Duration=.5},R15LeftSlash={Animation=R15Anims:WaitForChild("\076\101\102\116\083\108\097\115\104"),FadeTime=nil,Weight=nil,Speed=1.5,Duration=.5};R15RightSlash={Animation=R15Anims:WaitForChild("\082\105\103\104\116\083\108\097\115\104"),FadeTime=nil,Weight=nil,Speed=1.5,Duration=.5},R15SideSwipe={Animation=R15Anims:WaitForChild("\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")}ToolEquipped=false Remotes=Tool:FindFirstChild("\082\101\109\111\116\101\115")or(Create("\070\111\108\100\101\114"))({Name="\082\101\109\111\116\101\115",Parent=Tool})ServerControl=Remotes: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=Remotes})ClientControl=Remotes: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=Remotes})Handle.Transparency=0 Tool.Enabled=true function IsTeamMate(L,C)return L and(C and(not L.Neutral and(not C.Neutral and L.TeamColor==C.TeamColor)))end function TagHumanoid(L,C)local u=(Create("\079\098\106\101\099\116\086\097\108\117\101"))({Name="\099\114\101\097\116\111\114";Value=C})Debris:AddItem(u,2)u.Parent=L end function UntagHumanoid(L)for L,C in pairs(L:GetChildren())do if C:IsA("\079\098\106\101\099\116\086\097\108\117\101")and C.Name=="\099\114\101\097\116\111\114"then C:Destroy()end end end function CheckTableForInstance(L,C)for L,u in pairs(L)do if u==C then return true end end return false end function DealDamage(L,C)if not CheckIfAlive()or not L then return end local u=C or 0 local M=L:FindFirstChild("\072\117\109\097\110\111\105\100")local a=L:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")or L:FindFirstChild("\084\111\114\115\111")if not M or M.Health==0 or not a then return end UntagHumanoid(M)TagHumanoid(M,Player)M:TakeDamage(u)end function CheckIfAlive()return(Character and(Character.Parent and(Humanoid and(Humanoid.Parent and Humanoid.Health>0))))and true or false end function Blow(L)local C local u=false C=L.Touched:connect(function(L)if not L or not L.Parent or not CheckIfAlive()or not ToolEquipped or u then return end local C=Character:FindFirstChild("\082\105\103\104\116 \065\114\109")or Character:FindFirstChild("\082\105\103\104\116\072\097\110\100")if not C then return end local M=C:FindFirstChild("\082\105\103\104\116\071\114\105\112")if not M or M.Part0~=Handle and M.Part1~=Handle then return end local a=L.Parent if a==Character then return end local I=a:FindFirstChild("\072\117\109\097\110\111\105\100")if not I or I.Health==0 then return end local x=Players:GetPlayerFromCharacter(a)if x and(x==Player or IsTeamMate(Player,x))then return end u=true local N=Damage DealDamage(a,N)local B=tick()wait(.05)u=false end)end function Attack()Damage=DamageValues.SlashDamage Sounds.Slash:Play()local L=Humanoid.RigType==Enum.HumanoidRigType.R6 and{Animations.R6LeftSlash,Animations.R6RightSlash,Animations.R6SideSwipe}or Humanoid.RigType==Enum.HumanoidRigType.R15 and{Animations.R15LeftSlash;Animations.R15SideSwipe}local C=L[math.random(1,#L)]Spawn(function()InvokeClient("\080\108\097\121\065\110\105\109\097\116\105\111\110",C)end)wait(C.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 Humanoid.WalkSpeed=17 Sounds.Unsheath:Play()ToolEquipped=true end function Unequipped()if CheckIfAlive()then Humanoid.WalkSpeed=16 end ToolEquipped=false end function OnServerInvoke(L,C,u)if L~=Player or not ToolEquipped or not u or not CheckIfAlive()then return end end function InvokeClient(L,C)local u=nil pcall(function()u=ClientControl:InvokeClient(Player,L,C)end)return u end ServerControl.OnServerInvoke=OnServerInvoke Tool.Activated:connect(Activated)Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)Blow(Handle)


Tool = script.Parent
Handle = Tool:WaitForChild("Handle")

Players = game:GetService("Players")
Debris = game:GetService("Debris")
RunService = game:GetService("RunService")

RbxUtility = LoadLibrary("RbxUtility")
Create = RbxUtility.Create

DamageValues = {
	BaseDamage = 10,
	SlashDamage = 20,
}

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

Rate = (1 / 60)

AnimationsBin = Tool:WaitForChild("Animations")
R6Anims = AnimationsBin:WaitForChild("R6")
R15Anims = AnimationsBin:WaitForChild("R15")

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

}

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

ToolEquipped = false

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

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") or character:FindFirstChild("Torso")
	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")
		if not humanoid or humanoid.Health == 0 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()
		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.R6LeftSlash, Animations.R6RightSlash, Animations.R6SideSwipe})
	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
	Humanoid.WalkSpeed = (17)
	Sounds.Unsheath:Play()
	ToolEquipped = true
end

function Unequipped()
	if CheckIfAlive() then
		Humanoid.WalkSpeed = 16
	end
	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)
