local p={R15Slash=522635514,R15Lunge=522638767}local A=DamageValues.BaseDamage local l={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)}local G={Slash=Handle:WaitForChild("\083\119\105\110\103"),Lunge=Handle:WaitForChild("\083\119\105\110\103");Unsheath=Handle:WaitForChild("\085\110\115\104\101\097\116\104")}local c=false Tool.Grip=l.Up Tool.Enabled=true function IsTeamMate(p,A)return p and(A and(not p.Neutral and(not A.Neutral and p.TeamColor==A.TeamColor)))end function TagHumanoid(p,A)local l=Instance.new("\079\098\106\101\099\116\086\097\108\117\101")l.Name="\099\114\101\097\116\111\114"l.Value=A Debris:AddItem(l,2)l.Parent=p end function UntagHumanoid(p)for p,A in pairs(p:GetChildren())do if A:IsA("\079\098\106\101\099\116\086\097\108\117\101")and A.Name=="\099\114\101\097\116\111\114"then A:Destroy()end end end repeat wait(.3)until Tool.Parent:FindFirstChildWhichIsA("\072\117\109\097\110\111\105\100")local X=RaycastParams.new()X.FilterDescendantsInstances=workspace.characters:GetChildren()X.FilterType=Enum.RaycastFilterType.Blacklist local f=RaycastHitbox.new(script.Parent:WaitForChild("\072\097\110\100\108\101"))f.RaycastParams=X f.OnHit:Connect(function(p,A)f:HitStop()f:HitStart()if not p or not p.Parent or not CheckIfAlive()or not c then return end if not A then return end local l=p.Parent if l==Character then return end local G=Players:GetPlayerFromCharacter(l)if G and(G==Player or IsTeamMate(Player,G))then return end UntagHumanoid(A)TagHumanoid(A,Player)if Tool.Parent.Parent~=A.Parent.Parent then local A=Character.Torso.CFrame.lookVector local l=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")l.Name="\087\105\110\100\069\102\102\101\099\116"l.maxForce=Vector3.new(10000000.0,10000000.0,10000000.0)l.P=125 l.velocity=Vector3.new(A.X,A.Y,A.Z)*25+Vector3.new(0,15,0)l.Parent=p.Parent.Torso game.Debris:AddItem(l,.25)end end)local function o()A=DamageValues.SlashDamage G.Slash:Play()if Humanoid then if Humanoid.RigType==Enum.HumanoidRigType.R6 then local p=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")p.Name="\116\111\111\108\097\110\105\109"p.Value="\083\108\097\115\104"p.Parent=Tool elseif Humanoid.RigType==Enum.HumanoidRigType.R15 then local p=Tool:FindFirstChild("\082\049\053\083\108\097\115\104")if p then local A=Humanoid:LoadAnimation(p)A:Play(0)end end end end local function m()A=DamageValues.LungeDamage G.Lunge:Play()if Humanoid then if Humanoid.RigType==Enum.HumanoidRigType.R6 then local p=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")p.Name="\116\111\111\108\097\110\105\109"p.Value="\076\117\110\103\101"p.Parent=Tool elseif Humanoid.RigType==Enum.HumanoidRigType.R15 then local p=Tool:FindFirstChild("\082\049\053\076\117\110\103\101")if p then local A=Humanoid:LoadAnimation(p)A:Play(0)end end end wait(.2)Tool.Grip=l.Out wait(.6)Tool.Grip=l.Up A=DamageValues.SlashDamage end Tool.Enabled=true LastAttack=0 local function q()if not Tool.Enabled or not c or not CheckIfAlive()then return end Tool.Enabled=false local l=RunService.Stepped:wait()if l-LastAttack<.2 then m()else o()end LastAttack=l A=DamageValues.BaseDamage local G=Tool:FindFirstChild("\082\049\053\083\108\097\115\104")or(Create("\065\110\105\109\097\116\105\111\110"))({Name="\082\049\053\083\108\097\115\104";AnimationId=BaseUrl..p.R15Slash;Parent=Tool})local X=Tool:FindFirstChild("\082\049\053\076\117\110\103\101")or(Create("\065\110\105\109\097\116\105\111\110"))({Name="\082\049\053\076\117\110\103\101";AnimationId=BaseUrl..p.R15Lunge;Parent=Tool})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:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")Torso=Character:FindFirstChild("\084\111\114\115\111")or Character:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if not CheckIfAlive()then return end c=true G.Unsheath:Play()f:HitStart()end function Unequipped()Tool.Grip=l.Up c=false f:HitStop()end Tool.Activated:Connect(q)Tool.Equipped:Connect(Equipped)Tool.Unequipped:Connect(Unequipped)
--For R15 avatars
local Animations = {
	R15Slash = 522635514,
	R15Lunge = 522638767,
}

local Damage = DamageValues.BaseDamage

local 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),
}

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

local 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

repeat
	wait(0.3)
until Tool.Parent:FindFirstChildWhichIsA("Humanoid")

local params = RaycastParams.new()
params.FilterDescendantsInstances = workspace.characters:GetChildren()
params.FilterType = Enum.RaycastFilterType.Blacklist

local hitBox = RaycastHitbox.new(script.Parent:WaitForChild("Handle"))
hitBox.RaycastParams = params

hitBox.OnHit:Connect(function(Hit, humanoid)
	hitBox:HitStop()

	hitBox:HitStart()

	if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
		return
	end
	if not humanoid then
		return
	end
	local character = Hit.Parent
	if character == Character 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)

	if Tool.Parent.Parent ~= humanoid.Parent.Parent then
		local d = Character.Torso.CFrame.lookVector
		local force = Instance.new("BodyVelocity")
		force.Name = "WindEffect"
		force.maxForce = Vector3.new(1e7, 1e7, 1e7)
		force.P = 125
		force.velocity = (Vector3.new(d.X, d.Y, d.Z) * 25) + Vector3.new(0, 15, 0)
		force.Parent = Hit.Parent.Torso

		game.Debris:AddItem(force, 0.25)
	end
end)

local function Attack()
	Damage = DamageValues.SlashDamage
	Sounds.Slash:Play()

	if Humanoid then
		if Humanoid.RigType == Enum.HumanoidRigType.R6 then
			local Anim = Instance.new("StringValue")
			Anim.Name = "toolanim"
			Anim.Value = "Slash"
			Anim.Parent = Tool
		elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
			local Anim = Tool:FindFirstChild("R15Slash")
			if Anim then
				local Track = Humanoid:LoadAnimation(Anim)
				Track:Play(0)
			end
		end
	end
end

local function Lunge()
	Damage = DamageValues.LungeDamage

	Sounds.Lunge:Play()

	if Humanoid then
		if Humanoid.RigType == Enum.HumanoidRigType.R6 then
			local Anim = Instance.new("StringValue")
			Anim.Name = "toolanim"
			Anim.Value = "Lunge"
			Anim.Parent = Tool
		elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
			local Anim = Tool:FindFirstChild("R15Lunge")
			if Anim then
				local Track = Humanoid:LoadAnimation(Anim)
				Track:Play(0)
			end
		end
	end

	wait(0.2)
	Tool.Grip = Grips.Out
	wait(0.6)
	Tool.Grip = Grips.Up

	Damage = DamageValues.SlashDamage
end

Tool.Enabled = true
LastAttack = 0

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

	Tool.Enabled = false
	local Tick = RunService.Stepped:wait()
	if Tick - LastAttack < 0.2 then
		Lunge()
	else
		Attack()
	end

	LastAttack = Tick
	--wait(0.5)
	Damage = DamageValues.BaseDamage
	local SlashAnim = (
		Tool:FindFirstChild("R15Slash")
		or Create("Animation")({
			Name = "R15Slash",
			AnimationId = BaseUrl .. Animations.R15Slash,
			Parent = Tool,
		})
	)

	local LungeAnim = (
		Tool:FindFirstChild("R15Lunge")
		or Create("Animation")({
			Name = "R15Lunge",
			AnimationId = BaseUrl .. Animations.R15Lunge,
			Parent = Tool,
		})
	)
	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:FindFirstChildOfClass("Humanoid")
	Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
	if not CheckIfAlive() then
		return
	end
	ToolEquipped = true
	Sounds.Unsheath:Play()
	hitBox:HitStart()
end

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

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