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(I,j)if I=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(j and(ToolEquipped and Humanoid))then for I,b in pairs(Animations)do if b.Animation==j.Animation then b.AnimationTrack:Stop()table.remove(Animations,I)end end local I=Humanoid:LoadAnimation(j.Animation)table.insert(Animations,{Animation=j.Animation,AnimationTrack=I})I:Play(j.FadeTime,j.Weight,j.Speed)elseif I=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and j then for I,b in pairs(Animations)do if b.Animation==j.Animation then b.AnimationTrack:Stop()table.remove(Animations,I)end end end end function CheckIfAlive()return(Player and(Player.Parent and(Humanoid and(Humanoid.Parent and Humanoid.Health>0))))and true or false end function Equipped(I)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()I.Button1Down:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=true})end)I.Button1Up:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=false})end)I.KeyDown:connect(function(I)InvokeServer("\075\101\121\080\114\101\115\115",{Key=I;Down=true})end)I.KeyUp:connect(function(I)InvokeServer("\075\101\121\080\114\101\115\115",{Key=I,Down=false})end)end function Unequipped()ToolEquipped=false LocalObjects={}for I,j in pairs(Animations)do if j and j.AnimationTrack then j.AnimationTrack:Stop()end end for I,j in pairs({ObjectLocalTransparencyModifier})do if j then j:disconnect()end end Animations={}end function InvokeServer(I,j)pcall(function()local b=ServerControl:InvokeServer(I,j)return b end)end function OnClientInvoke(I,j)if I=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(j and(ToolEquipped and Humanoid))then SetAnimation("\080\108\097\121\065\110\105\109\097\116\105\111\110",j)elseif I=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and j then SetAnimation("\083\116\111\112\065\110\105\109\097\116\105\111\110",j)elseif I=="\080\108\097\121\083\111\117\110\100"and j then j:Play()elseif I=="\083\116\111\112\083\111\117\110\100"and j then j:Stop()elseif I=="\077\111\117\115\101\080\111\115\105\116\105\111\110"then return PlayerMouse.Hit.p elseif I=="\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(j and ToolEquipped)then pcall(function()local I=false for b,o in pairs(LocalObjects)do if o==j then I=true end end if not I then table.insert(LocalObjects,j)if ObjectLocalTransparencyModifier then ObjectLocalTransparencyModifier:disconnect()end ObjectLocalTransparencyModifier=RunService.RenderStepped:connect(function()for I,j in pairs(LocalObjects)do if j.Object and j.Object.Parent then if not j.AutoUpdate and(j.Object.LocalTransparencyModifier==1 or j.Object.LocalTransparencyModifier==0)or j.AutoUpdate then j.Object.LocalTransparencyModifier=j.Transparency end else table.remove(LocalObjects,I)end end end)end end)end end Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)ClientControl.OnClientInvoke=OnClientInvoke
--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 CheckIfAlive()
	return (((Player and Player.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0) 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)
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({ ObjectLocalTransparencyModifier }) do
		if v then
			v:disconnect()
		end
	end
	Animations = {}
end

function InvokeServer(Mode, Value)
	pcall(function()
		local ServerReturn = ServerControl:InvokeServer(Mode, Value)
		return ServerReturn
	end)
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 PlayerMouse.Hit.p
	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
							if
								(
									not v.AutoUpdate
									and (
										v.Object.LocalTransparencyModifier == 1
										or v.Object.LocalTransparencyModifier == 0
									)
								) or v.AutoUpdate
							then
								v.Object.LocalTransparencyModifier = v.Transparency
							end
						else
							table.remove(LocalObjects, i)
						end
					end
				end)
			end
		end)
	end
end

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