Tool=script.Parent Handle=Tool:WaitForChild("\072\097\110\100\108\101")Players=game:GetService("\080\108\097\121\101\114\115")RunService=game:GetService("\082\117\110\083\101\114\118\105\099\101")Camera=(game:GetService("\087\111\114\107\115\112\097\099\101")).CurrentCamera Animations={}LocalObjects={}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")ToolEquipped=false function SetAnimation(q,B)if q=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(B and(ToolEquipped and Humanoid))then for q,j in pairs(Animations)do if j.Animation==B.Animation then j.AnimationTrack:Stop()table.remove(Animations,q)end end local q=Humanoid:LoadAnimation(B.Animation)table.insert(Animations,{Animation=B.Animation;AnimationTrack=q})q:Play(B.FadeTime,B.Weight,B.Speed)elseif q=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and B then for q,j in pairs(Animations)do if j.Animation==B.Animation then j.AnimationTrack:Stop()table.remove(Animations,q)end end end end function DisableJump(q)if PreventJump then PreventJump:disconnect()end if q then PreventJump=Humanoid.Changed:connect(function(q)if q=="\074\117\109\112"then Humanoid.Jump=false end end)end end function CheckIfAlive()return(Character and(Character.Parent and(Humanoid and(Humanoid.Parent and(Humanoid.Health>0 and(Player and Player.Parent))))))and true or false end function Equipped(q)Character=Tool.Parent Player=Players:GetPlayerFromCharacter(Character)Humanoid=Character:FindFirstChild("\072\117\109\097\110\111\105\100")ToolEquipped=true if not CheckIfAlive()then return end PlayerMouse=Player:GetMouse()q.Button1Down:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=true})end)q.Button1Up:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=false})end)q.KeyDown:connect(function(q)InvokeServer("\075\101\121\080\114\101\115\115",{Key=q,Down=true})end)q.KeyUp:connect(function(q)InvokeServer("\075\101\121\080\114\101\115\115",{Key=q;Down=false})end)q.Move:connect(function()InvokeServer("\077\111\117\115\101\077\111\118\101",{Position=q.Hit.p,Target=q.Target})end)end function Unequipped()ToolEquipped=false LocalObjects={}for q,B in pairs(Animations)do if B and B.AnimationTrack then B.AnimationTrack:Stop()end end for q,B in pairs({PreventJump,ObjectLocalTransparencyModifier})do if B then B:disconnect()end end Animations={}end function InvokeServer(q,B)local j pcall(function()j=ServerControl:InvokeServer(q,B)end)return j end function OnClientInvoke(q,B)if q=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(B and(ToolEquipped and Humanoid))then SetAnimation("\080\108\097\121\065\110\105\109\097\116\105\111\110",B)elseif q=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and B then SetAnimation("\083\116\111\112\065\110\105\109\097\116\105\111\110",B)elseif q=="\080\108\097\121\083\111\117\110\100"and B then B:Play()elseif q=="\083\116\111\112\083\111\117\110\100"and B then B:Stop()elseif q=="\077\111\117\115\101\080\111\115\105\116\105\111\110"then return{Position=PlayerMouse.Hit.p,Target=PlayerMouse.Target}elseif q=="\068\105\115\097\098\108\101\074\117\109\112"then DisableJump(B)elseif q=="\083\101\116\076\111\099\097\108\084\114\097\110\115\112\097\114\101\110\099\121\077\111\100\105\102\105\101\114"and(B and ToolEquipped)then pcall(function()local q=false for j,S in pairs(LocalObjects)do if S==B then q=true end end if not q then table.insert(LocalObjects,B)if ObjectLocalTransparencyModifier then ObjectLocalTransparencyModifier:disconnect()end ObjectLocalTransparencyModifier=RunService.RenderStepped:connect(function()for q,B in pairs(LocalObjects)do if B.Object and B.Object.Parent then local q=B.Object.LocalTransparencyModifier if not B.AutoUpdate and(q==1 or q==0)or B.AutoUpdate then B.Object.LocalTransparencyModifier=B.Transparency end else table.remove(LocalObjects,q)end end end)end end)end end ClientControl.OnClientInvoke=OnClientInvoke Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)
--Made by Luckymaxer

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

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

Camera = game:GetService("Workspace").CurrentCamera

Animations = {}
LocalObjects = {}

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

ToolEquipped = false

function SetAnimation(mode, value)
	if mode == "PlayAnimation" and value and ToolEquipped 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
	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 (
		(
			(
				Character
				and Character.Parent
				and Humanoid
				and Humanoid.Parent
				and Humanoid.Health > 0
				and Player
				and Player.Parent
			) and true
		) or false
	)
end

function Equipped(Mouse)
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	ToolEquipped = true
	if not CheckIfAlive() then
		return
	end
	PlayerMouse = Player:GetMouse()
	Mouse.Button1Down:connect(function()
		InvokeServer("MouseClick", { Down = true })
	end)
	Mouse.Button1Up:connect(function()
		InvokeServer("MouseClick", { Down = false })
	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)
	Mouse.Move:connect(function()
		InvokeServer("MouseMove", { Position = Mouse.Hit.p, Target = Mouse.Target })
	end)
end

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

function InvokeServer(mode, value)
	local ServerReturn
	pcall(function()
		ServerReturn = ServerControl:InvokeServer(mode, value)
	end)
	return ServerReturn
end

function OnClientInvoke(mode, value)
	if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
		SetAnimation("PlayAnimation", value)
	elseif mode == "StopAnimation" and value then
		SetAnimation("StopAnimation", value)
	elseif mode == "PlaySound" and value then
		value:Play()
	elseif mode == "StopSound" and value then
		value:Stop()
	elseif mode == "MousePosition" then
		return { Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target }
	elseif mode == "DisableJump" then
		DisableJump(value)
	elseif mode == "SetLocalTransparencyModifier" and value and ToolEquipped then
		pcall(function()
			local ObjectFound = false
			for i, v in pairs(LocalObjects) do
				if v == value then
					ObjectFound = true
				end
			end
			if not ObjectFound then
				table.insert(LocalObjects, value)
				if ObjectLocalTransparencyModifier then
					ObjectLocalTransparencyModifier:disconnect()
				end
				ObjectLocalTransparencyModifier = RunService.RenderStepped:connect(function()
					for i, v in pairs(LocalObjects) do
						if v.Object and v.Object.Parent then
							local CurrentTransparency = v.Object.LocalTransparencyModifier
							if
								(not v.AutoUpdate and (CurrentTransparency == 1 or CurrentTransparency == 0))
								or v.AutoUpdate
							then
								v.Object.LocalTransparencyModifier = v.Transparency
							end
						else
							table.remove(LocalObjects, i)
						end
					end
				end)
			end
		end)
	end
end

ClientControl.OnClientInvoke = OnClientInvoke
Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
