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")InputCheck=Instance.new("\083\099\114\101\101\110\071\117\105")InputCheck.Name="\073\110\112\117\116\067\104\101\099\107"InputButton=Instance.new("\070\114\097\109\101")InputButton.Name="\073\110\112\117\116\077\111\110\105\116\111\114"InputButton.BackgroundTransparency=1 InputButton.Size=UDim2.new(1,0,1,0)InputButton.Parent=InputCheck 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(o,M)if not ToolEquipped or not CheckIfAlive()then return end if o=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(M and(ToolEquipped and Humanoid))then for o,U in pairs(Animations)do if U.Animation==M.Animation then U.AnimationTrack:Stop()table.remove(Animations,o)end end local o=Humanoid:LoadAnimation(M.Animation)table.insert(Animations,{Animation=M.Animation;AnimationTrack=o})o:Play(M.FadeTime,M.Weight,M.Speed)elseif o=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and M then for o,U in pairs(Animations)do if U.Animation==M.Animation then U.AnimationTrack:Stop(M.FadeTime)table.remove(Animations,o)end end end end function DisableJump(o)if PreventJump then PreventJump:disconnect()end if o then PreventJump=Humanoid.Changed:connect(function(o)if o=="\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(o)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=o o.KeyDown:connect(function(o)InvokeServer("\075\101\121\080\114\101\115\115",{Key=o,Down=true})end)o.KeyUp:connect(function(o)InvokeServer("\075\101\121\080\114\101\115\115",{Key=o;Down=false})end)o.Button1Down:connect(function()InvokeServer("\077\111\117\115\101\068\111\119\110",{Down=true})end)o.Button1Up:connect(function()InvokeServer("\077\111\117\115\101\068\111\119\110",{Down=false})end)local M=Player:FindFirstChild("\080\108\097\121\101\114\071\117\105")if M then if UserInputService.TouchEnabled then InputCheckClone=InputCheck:Clone()InputCheckClone.InputMonitor.InputBegan:connect(function()InvokeServer("\066\117\116\116\111\110\049\067\108\105\099\107",{Down=true})end)InputCheckClone.InputMonitor.InputEnded:connect(function()InvokeServer("\066\117\116\116\111\110\049\067\108\105\099\107",{Down=false})end)InputCheckClone.Parent=M end end end function Unequipped()ToolEquipped=false if InputCheckClone and InputCheckClone.Parent then InputCheckClone:Destroy()end for o,M in pairs(Animations)do if M and M.AnimationTrack then M.AnimationTrack:Stop()end end for o,M in pairs(LocalObjects)do if M.Object then M.Object.LocalTransparencyModifier=0 end end for o,M in pairs({PreventJump;ObjectLocalTransparencyModifier})do if M then M:disconnect()end end Animations={}LocalObjects={}end function InvokeServer(o,M)local U pcall(function()U=ServerControl:InvokeServer(o,M)end)return U end function OnClientInvoke(o,M)if not ToolEquipped or not CheckIfAlive()or not o then return end if o=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and M then SetAnimation("\080\108\097\121\065\110\105\109\097\116\105\111\110",M)elseif o=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and M then SetAnimation("\083\116\111\112\065\110\105\109\097\116\105\111\110",M)elseif o=="\080\108\097\121\083\111\117\110\100"and M then M:Play()elseif o=="\083\116\111\112\083\111\117\110\100"and M then M:Stop()elseif o=="\077\111\117\115\101\068\097\116\097"then return{Position=PlayerMouse.Hit.p,Target=PlayerMouse.Target}elseif o=="\068\105\115\097\098\108\101\074\117\109\112"then DisableJump(M)elseif o=="\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 M then pcall(function()local o=false for U,k in pairs(LocalObjects)do if k==M then o=true end end if not o then table.insert(LocalObjects,M)if ObjectLocalTransparencyModifier then ObjectLocalTransparencyModifier:disconnect()end ObjectLocalTransparencyModifier=RunService.RenderStepped:connect(function()local o=(game:GetService("\087\111\114\107\115\112\097\099\101")).CurrentCamera for M,U in pairs(LocalObjects)do if U.Object and U.Object.Parent then local M=U.Object.LocalTransparencyModifier local k=(o.CoordinateFrame.p-Head.Position).Magnitude if not U.AutoUpdate and(M==1 or M==0)or U.AutoUpdate then if U.Distance and k<=U.Distance or not U.Distance then U.Object.LocalTransparencyModifier=U.Transparency else U.Object.LocalTransparencyModifier=0 end end else table.remove(LocalObjects,M)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")

InputCheck = Instance.new("ScreenGui")
InputCheck.Name = "InputCheck"
InputButton = Instance.new("Frame")
InputButton.Name = "InputMonitor"
InputButton.BackgroundTransparency = 1
InputButton.Size = UDim2.new(1, 0, 1, 0)
InputButton.Parent = InputCheck

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 = Mouse
	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.Button1Down:connect(function()
		InvokeServer("MouseDown", { Down = true })
	end)
	Mouse.Button1Up:connect(function()
		InvokeServer("MouseDown", { Down = false })
	end)
	local PlayerGui = Player:FindFirstChild("PlayerGui")
	if PlayerGui then
		if UserInputService.TouchEnabled then
			InputCheckClone = InputCheck:Clone()
			InputCheckClone.InputMonitor.InputBegan:connect(function()
				InvokeServer("Button1Click", { Down = true })
			end)
			InputCheckClone.InputMonitor.InputEnded:connect(function()
				InvokeServer("Button1Click", { Down = false })
			end)
			InputCheckClone.Parent = PlayerGui
		end
	end
end

function Unequipped()
	ToolEquipped = false
	if InputCheckClone and InputCheckClone.Parent then
		InputCheckClone:Destroy()
	end
	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)
