Tool=script.Parent Handle=Tool:WaitForChild("\072\097\110\100\108\101")Players=game:GetService("\080\108\097\121\101\114\115")ContentProvider=game:GetService("\067\111\110\116\101\110\116\080\114\111\118\105\100\101\114")Animations={}ServerControl=Tool:WaitForChild("\083\101\114\118\101\114\067\111\110\116\114\111\108")ClientControl=Tool:WaitForChild("\067\108\105\101\110\116\067\111\110\116\114\111\108")Equipped=false ClientControl.OnClientInvoke=function(J,v)if J=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(Equipped and Humanoid)then for J,L in pairs(Animations)do if L.Animation==v.Animation then L.AnimationTrack:Stop()table.remove(Animations,J)end end local J=Humanoid:LoadAnimation(v.Animation)table.insert(Animations,{Animation=v.Animation,AnimationTrack=J})J:Play(v.FadeTime,v.Weight,v.Speed)elseif J=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and v then for J,L in pairs(Animations)do if L.Animation==v.Animation then L.AnimationTrack:Stop()table.remove(Animations,J)end end elseif J=="\080\114\101\108\111\097\100"and v then ContentProvider:Preload(v)elseif J=="\080\108\097\121\083\111\117\110\100"and v then v:Play()elseif J=="\083\116\111\112\083\111\117\110\100"and v then v:Stop()elseif J=="\077\111\117\115\101\080\111\115\105\116\105\111\110"then return PlayerMouse.Hit.p elseif J=="\068\105\115\097\098\108\101\074\117\109\112"then DisableJump(v)end end function InvokeServer(J,v)pcall(function()local L=ServerControl:InvokeServer(J,v)return L end)end function DisableJump(J)if PreventJump then PreventJump:disconnect()end if J then PreventJump=Humanoid.Changed:connect(function(J)if J=="\074\117\109\112"then Humanoid.Jump=false end end)end end function CheckIfAlive()return Player and(Player.Parent and(Humanoid and(Humanoid.Parent and Humanoid.Health>0)))end function Equipped(J)Character=Tool.Parent Player=Players:GetPlayerFromCharacter(Character)Humanoid=Character:FindFirstChild("\072\117\109\097\110\111\105\100")Equipped=true if not CheckIfAlive()then return end PlayerMouse=Player:GetMouse()J.Button1Down:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=true})end)J.KeyDown:connect(function(J)InvokeServer("\075\101\121\080\114\101\115\115",{Key=J,Down=true})end)J.KeyUp:connect(function(J)InvokeServer("\075\101\121\080\114\101\115\115",{Key=J;Down=false})end)end function Unequipped()Equipped=false for J,v in pairs(Animations)do if v and v.AnimationTrack then v.AnimationTrack:Stop()end end if PreventJump then PreventJump:disconnect()end Animations={}end Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)
--Made by Luckymaxer

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

Players = game:GetService("Players")
ContentProvider = game:GetService("ContentProvider")

Animations = {}

ServerControl = Tool:WaitForChild("ServerControl")
ClientControl = Tool:WaitForChild("ClientControl")

Equipped = false

ClientControl.OnClientInvoke = function(Mode, Value)
	if Mode == "PlayAnimation" and Equipped and Humanoid then
		for i, v in pairs(Animations) do
			if v.Animation == Value.Animation then
				v.AnimationTrack:Stop()
				table.remove(Animations, i)
			end
		end
		local AnimationTrack = Humanoid:LoadAnimation(Value.Animation)
		table.insert(Animations, { Animation = Value.Animation, AnimationTrack = AnimationTrack })
		AnimationTrack:Play(Value.FadeTime, Value.Weight, Value.Speed)
	elseif Mode == "StopAnimation" and Value then
		for i, v in pairs(Animations) do
			if v.Animation == Value.Animation then
				v.AnimationTrack:Stop()
				table.remove(Animations, i)
			end
		end
	elseif Mode == "Preload" and Value then
		ContentProvider:Preload(Value)
	elseif Mode == "PlaySound" and Value then
		Value:Play()
	elseif Mode == "StopSound" and Value then
		Value:Stop()
	elseif Mode == "MousePosition" then
		return PlayerMouse.Hit.p
	elseif Mode == "DisableJump" then
		DisableJump(Value)
	end
end

function InvokeServer(Mode, Value)
	pcall(function()
		local ServerReturn = ServerControl:InvokeServer(Mode, Value)
		return ServerReturn
	end)
end

function DisableJump(Boolean)
	if PreventJump then
		PreventJump:disconnect()
	end
	if Boolean then
		PreventJump = Humanoid.Changed:connect(function(Property)
			if Property == "Jump" then
				Humanoid.Jump = false
			end
		end)
	end
end

function CheckIfAlive()
	return (Player and Player.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0)
end

function Equipped(Mouse)
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	Equipped = true
	if not CheckIfAlive() then
		return
	end
	PlayerMouse = Player:GetMouse()
	Mouse.Button1Down:connect(function()
		InvokeServer("MouseClick", { Down = true })
	end)
	Mouse.KeyDown:connect(function(Key)
		InvokeServer("KeyPress", { Key = Key, Down = true })
	end)
	Mouse.KeyUp:connect(function(Key)
		InvokeServer("KeyPress", { Key = Key, Down = false })
	end)
end

function Unequipped()
	Equipped = false
	for i, v in pairs(Animations) do
		if v and v.AnimationTrack then
			v.AnimationTrack:Stop()
		end
	end
	if PreventJump then
		PreventJump:disconnect()
	end
	Animations = {}
end

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