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

Animations = {}
LocalObjects = {}

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

ToolEquipped = false

function SetAnimation(mode, value)
	if not ToolEquipped or not CheckIfAlive() then
		return
	end
	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(value.FadeTime)
				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 Head
				and Head.Parent
				and Player
				and Player.Parent
			) and true
		) or false
	)
end

function Equipped(Mouse)
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	Head = Character:FindFirstChild("Head")
	ToolEquipped = true
	if not CheckIfAlive() then
		return
	end
	PlayerMouse = Player:GetMouse()
	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
	for i, v in pairs(Animations) do
		if v and v.AnimationTrack then
			v.AnimationTrack:Stop()
		end
	end
	for i, v in pairs(LocalObjects) do
		if v.Object then
			v.Object.LocalTransparencyModifier = 0
		end
	end
	for i, v in pairs({ PreventJump, ObjectLocalTransparencyModifier }) do
		if v then
			v:disconnect()
		end
	end
	Animations = {}
	LocalObjects = {}
end

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

function OnClientInvoke(mode, value)
	if not ToolEquipped or not CheckIfAlive() or not mode then
		return
	end
	if mode == "PlayAnimation" and value 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 == "MouseData" then
		return { Position = PlayerMouse.Hit.p, Target = PlayerMouse.Target }
	elseif mode == "DisableJump" then
		DisableJump(value)
	elseif mode == "SetLocalTransparencyModifier" and value 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()
					local Camera = game:GetService("Workspace").CurrentCamera
					for i, v in pairs(LocalObjects) do
						if v.Object and v.Object.Parent then
							local CurrentTransparency = v.Object.LocalTransparencyModifier
							local ViewDistance = (Camera.CoordinateFrame.p - Head.Position).Magnitude
							if
								(not v.AutoUpdate and (CurrentTransparency == 1 or CurrentTransparency == 0))
								or v.AutoUpdate
							then
								if (v.Distance and ViewDistance <= v.Distance) or not v.Distance then
									v.Object.LocalTransparencyModifier = v.Transparency
								else
									v.Object.LocalTransparencyModifier = 0
								end
							end
						else
							table.remove(LocalObjects, i)
						end
					end
				end)
			end
		end)
	end
end

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