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")DamageValues={BaseDamage=5;SlashDamage=12;LungeDamage=16}Damage=DamageValues.BaseDamage Grips={Up=CFrame.new(0,0,-1.70000005,0,0,1,1,0,0,0,1,0);Out=CFrame.new(0,0,-1.70000005,0,1,0,1,0,0,0,0,-1)}Sounds={Slash=Handle:WaitForChild("\083\119\111\114\100\083\108\097\115\104");Lunge=Handle:WaitForChild("\083\119\111\114\100\076\117\110\103\101");Unsheath=Handle:WaitForChild("\085\110\115\104\101\097\116\104")}ToolEquipped=false Tool.Grip=Grips.Up Tool.Enabled=true function IsTeamMate(M,D)return M and(D and(not M.Neutral and(not D.Neutral and M.TeamColor==D.TeamColor)))end function TagHumanoid(M,D)local e=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")e.Name="\099\114\101\097\116\111\114"e.Value=D Debris:AddItem(e,2)e.Parent=M end function UntagHumanoid(M)for M,D in pairs(M:GetChildren())do if D:IsA("\079\098\106\101\099\116\086\097\108\117\101")and D.Name=="\099\114\101\097\116\111\114"then D:Destroy()end end end function Blow(M)if not M or not M.Parent or not CheckIfAlive()or not ToolEquipped then return end local D=Character:FindFirstChild("\082\105\103\104\116 \065\114\109")if not D then return end local e=D: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 k=M.Parent if k==Character then return end local n=k:FindFirstChild("\072\117\109\097\110\111\105\100")if not n or n.Health==0 then return end local i=Players:GetPlayerFromCharacter(k)if i and(i==Player or IsTeamMate(Player,i))then return end UntagHumanoid(n)TagHumanoid(n,Player)n:TakeDamage(Damage)end function Attack()Damage=DamageValues.SlashDamage Sounds.Slash:Play()local M=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")M.Name="\116\111\111\108\097\110\105\109"M.Value="\083\108\097\115\104"M.Parent=Tool end function Lunge()Damage=DamageValues.LungeDamage Sounds.Lunge:Play()local M=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")M.Name="\116\111\111\108\097\110\105\109"M.Value="\076\117\110\103\101"M.Parent=Tool if CheckIfAlive()then local M=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")M.velocity=Vector3.new(0,10,0)M.maxForce=Vector3.new(0,4000,0)Debris:AddItem(M,.4)M.Parent=Torso end wait(.2)Tool.Grip=Grips.Out wait(.6)Tool.Grip=Grips.Up Damage=DamageValues.SlashDamage end Tool.Enabled=true LastAttack=0 function Activated()if not Tool.Enabled or not ToolEquipped or not CheckIfAlive()then return end Tool.Enabled=false Tick=RunService.Stepped:wait()if Tick-LastAttack<.2 then Lunge()else Attack()end LastAttack=Tick 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(Torso and Torso.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")Torso=Character:FindFirstChild("\084\111\114\115\111")if not CheckIfAlive()then return end ToolEquipped=true Sounds.Unsheath:Play()end function Unequipped()Tool.Grip=Grips.Up ToolEquipped=false end Tool.Activated:connect(Activated)Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)Connection=Handle.Touched:connect(Blow)


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

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

DamageValues = {
	BaseDamage = 5,
	SlashDamage = 12,
	LungeDamage = 16
}

Damage = DamageValues.BaseDamage

Grips = {
	Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
	Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
}

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

ToolEquipped = false

Tool.Grip = Grips.Up
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 = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.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 Blow(Hit)
	if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
		return
	end
	local RightArm = Character:FindFirstChild("Right Arm")
	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
	UntagHumanoid(humanoid)
	TagHumanoid(humanoid, Player)
	humanoid:TakeDamage(Damage)	
end


function Attack()
	Damage = DamageValues.SlashDamage
	Sounds.Slash:Play()
	local Anim = Instance.new("StringValue")
	Anim.Name = "toolanim"
	Anim.Value = "Slash"
	Anim.Parent = Tool
end

function Lunge()
	Damage = DamageValues.LungeDamage

	Sounds.Lunge:Play()

	local Anim = Instance.new("StringValue")
	Anim.Name = "toolanim"
	Anim.Value = "Lunge"
	Anim.Parent = Tool
	
	if CheckIfAlive() then
		local Force = Instance.new("BodyVelocity")
		Force.velocity = Vector3.new(0, 10, 0) 
		Force.maxForce = Vector3.new(0, 4000, 0)
		Debris:AddItem(Force, 0.4)
		Force.Parent = Torso
	end
	
	wait(0.2)
	Tool.Grip = Grips.Out
	wait(0.6)
	Tool.Grip = Grips.Up

	Damage = DamageValues.SlashDamage
end

Tool.Enabled = true
LastAttack = 0

function Activated()

	if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
		return
	end

	Tool.Enabled = false

	Tick = RunService.Stepped:wait()

	if (Tick - LastAttack < 0.2) then
		Lunge()
	else
		Attack()
	end

	LastAttack = Tick

	--wait(0.5)

	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 Torso and Torso.Parent) and true) or false)
end

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

function Unequipped()
	Tool.Grip = Grips.Up
	ToolEquipped = false
end

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

Connection = Handle.Touched:connect(Blow)
