local function R(R,N)while not R:FindFirstChild(N)do R.ChildAdded:wait()end return R[N]end local N=script.Parent local p={}local t local C local function X(R)if p[R]then p[R]:Play()end end local function s(R)if p[R]then p[R]:Stop()end end function OnEquipped(s)C=N.Parent t=R(C,"\072\117\109\097\110\111\105\100")if t then p.EquipAnim=t:LoadAnimation(R(N,"\069\113\117\105\112\065\110\105\109\053"))p.IdleAnim=t:LoadAnimation(R(N,"\073\100\108\101\065\110\105\109\051"))p.OverheadAnim=t:LoadAnimation(R(N,"\079\118\101\114\104\101\097\100\065\110\105\109\050"))p.SlashAnim=t:LoadAnimation(R(N,"\083\108\097\115\104\065\110\105\109\050"))p.ThrustAnim=t:LoadAnimation(R(N,"\084\104\114\117\115\116\065\110\105\109\050"))p.UnequipAnim=t:LoadAnimation(R(N,"\085\110\101\113\117\105\112\065\110\105\109\050"))end s.KeyDown:connect(function(R)function Taunt()local R={}for p,t in pairs(game.Players:GetChildren())do if t~=game.Players:GetPlayerFromCharacter(N.Parent)then if t.Character and t.Character:FindFirstChild("\084\111\114\115\111")then R[#R+1]=t.Character.Torso end end end local p=N.Parent.Torso.Position for R,N in pairs(R)do if(p-N.Position).magnitude<40 then local R=(p-N.Position).unit local t=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")t.velocity=Vector3.new(0,1,0)t.Parent=N N.Velocity=R*250 game.Debris:AddItem(t,.5)end end end function rTaunt()local R={}for p,t in pairs(game.Players:GetChildren())do if t~=game.Players:GetPlayerFromCharacter(N.Parent)then if t.Character and t.Character:FindFirstChild("\084\111\114\115\111")then R[#R+1]=t.Character.Torso end end end local p=N.Parent.Torso.Position for R,N in pairs(R)do if(p-N.Position).magnitude<40 then local R=(p-N.Position).unit local t=Instance.new("\066\111\100\121\086\101\108\111\099\105\116\121")t.velocity=Vector3.new(0,1,0)t.Parent=N N.Velocity=-R*250 game.Debris:AddItem(t,.5)end end end if R=="\113"then if debounce==nil then debounce=true p.EquipAnim:Play(.1,.8,2)Taunt()wait(5)debounce=nil end elseif R=="\101"then if debounce2==nil then debounce2=true p.EquipAnim:Play(.1,.8,2)rTaunt()wait(5)debounce2=nil end end end)p.EquipAnim:Play(.1,.8,1)X("\073\100\108\101\065\110\105\109")end function OnUnequipped()N.Handle.deactivate:Play()for R,N in pairs(p)do s(R)end end N.Equipped:connect(OnEquipped)N.Unequipped:connect(OnUnequipped);(R(N,"\080\108\097\121\083\108\097\115\104")).Changed:connect(function(R)X("\083\108\097\115\104\065\110\105\109")end);(R(N,"\080\108\097\121\084\104\114\117\115\116")).Changed:connect(function(R)X("\084\104\114\117\115\116\065\110\105\109")end);(R(N,"\080\108\097\121\079\118\101\114\104\101\097\100")).Changed:connect(function(R)p.OverheadAnim:Play()end)
-- Waits for the child of the specified parent
local function WaitForChild(parent, childName)
	while not parent:FindFirstChild(childName) do
		parent.ChildAdded:wait()
	end
	return parent[childName]
end

local Tool = script.Parent

local Animations = {}
local MyHumanoid
local MyCharacter

local function PlayAnimation(animationName)
	if Animations[animationName] then
		Animations[animationName]:Play()
	end
end

local function StopAnimation(animationName)
	if Animations[animationName] then
		Animations[animationName]:Stop()
	end
end

function OnEquipped(mouse)
	MyCharacter = Tool.Parent
	MyHumanoid = WaitForChild(MyCharacter, "Humanoid")
	if MyHumanoid then
		Animations["EquipAnim"] = MyHumanoid:LoadAnimation(WaitForChild(Tool, "EquipAnim5"))
		Animations["IdleAnim"] = MyHumanoid:LoadAnimation(WaitForChild(Tool, "IdleAnim3"))
		Animations["OverheadAnim"] = MyHumanoid:LoadAnimation(WaitForChild(Tool, "OverheadAnim2"))
		Animations["SlashAnim"] = MyHumanoid:LoadAnimation(WaitForChild(Tool, "SlashAnim2"))
		Animations["ThrustAnim"] = MyHumanoid:LoadAnimation(WaitForChild(Tool, "ThrustAnim2"))
		Animations["UnequipAnim"] = MyHumanoid:LoadAnimation(WaitForChild(Tool, "UnequipAnim2"))
	end
	mouse.KeyDown:connect(function(key)
		function Taunt()
			--gather all of the humanoids in a 30stud radius
			local torsos = {}
			for _, p in pairs(game.Players:GetChildren()) do
				if p ~= game.Players:GetPlayerFromCharacter(Tool.Parent) then
					if p.Character and p.Character:FindFirstChild("Torso") then
						torsos[#torsos + 1] = p.Character.Torso
					end
				end
			end

			--now pull them in towards us
			local mpos = Tool.Parent.Torso.Position
			for _, torso in pairs(torsos) do
				if (mpos - torso.Position).magnitude < 40 then
					local dir = (mpos - torso.Position).unit
					------------ stolen from dagger of time to make a character "fly" in some direction
					local force = Instance.new("BodyVelocity")
					force.velocity = Vector3.new(0, 1, 0)
					force.Parent = torso
					torso.Velocity = dir * 250
					game.Debris:AddItem(force, 0.5)
					------------
				end
			end
		end

		function rTaunt()
			--gather all of the humanoids in a 30stud radius
			local torsos = {}
			for _, p in pairs(game.Players:GetChildren()) do
				if p ~= game.Players:GetPlayerFromCharacter(Tool.Parent) then
					if p.Character and p.Character:FindFirstChild("Torso") then
						torsos[#torsos + 1] = p.Character.Torso
					end
				end
			end

			--now pull them in towards us
			local mpos = Tool.Parent.Torso.Position
			for _, torso in pairs(torsos) do
				if (mpos - torso.Position).magnitude < 40 then
					local dir = (mpos - torso.Position).unit
					------------ stolen from dagger of time to make a character "fly" in some direction
					local force = Instance.new("BodyVelocity")
					force.velocity = Vector3.new(0, 1, 0)
					force.Parent = torso
					torso.Velocity = -dir * 250
					game.Debris:AddItem(force, 0.5)
					------------
				end
			end
		end

		if key == "q" then
			if debounce == nil then
				debounce = true
				Animations["EquipAnim"]:Play(0.1, 0.8, 2)
				Taunt()
				wait(5)
				debounce = nil
			end
		elseif key == "e" then
			if debounce2 == nil then
				debounce2 = true
				Animations["EquipAnim"]:Play(0.1, 0.8, 2)
				rTaunt()
				wait(5)
				debounce2 = nil
			end
		end
	end)

	Animations["EquipAnim"]:Play(0.1, 0.8, 1)
	PlayAnimation("IdleAnim")
end

function OnUnequipped()
	Tool.Handle.deactivate:Play()
	for animName, _ in pairs(Animations) do
		StopAnimation(animName)
	end
end

Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)

WaitForChild(Tool, "PlaySlash").Changed:connect(function(value)
	--if value then
	PlayAnimation("SlashAnim")
	--else
	--	StopAnimation('SlashAnim')
	--end
end)

WaitForChild(Tool, "PlayThrust").Changed:connect(function(value)
	--if value then
	PlayAnimation("ThrustAnim")
	--else
	--	StopAnimation('ThrustAnim')
	--end
end)

WaitForChild(Tool, "PlayOverhead").Changed:connect(function(value)
	--if value then
	Animations["OverheadAnim"]:Play()
	--else
	--	StopAnimation('OverheadAnim')
	--end
end)
