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={}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")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("\073\109\097\103\101\066\117\116\116\111\110")InputButton.Name="\073\110\112\117\116\066\117\116\116\111\110"InputButton.Image=""InputButton.BackgroundTransparency=1 InputButton.ImageTransparency=1 InputButton.Size=UDim2.new(1,0,1,0)InputButton.Parent=InputCheck ToolEquipped=false function SetAnimation(F,T)if F=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(T and(ToolEquipped and Humanoid))then local F=false for r,u in pairs(Animations)do if u.Animation==T.Animation then u.AnimationTrack:AdjustSpeed(T.Speed)F=true break end end if F then return end local r=Humanoid:LoadAnimation(T.Animation)table.insert(Animations,{Animation=T.Animation,AnimationTrack=r})r:Play(T.FadeTime,T.Weight,T.Speed)elseif F=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and T then for F,r in pairs(Animations)do if r.Animation==T.Animation then r.AnimationTrack:Stop(T.FadeTime)table.remove(Animations,F)end end end end function DisableJump(F)if PreventJump then PreventJump:disconnect()end if F then PreventJump=Humanoid.Changed:connect(function(F)if F=="\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(F)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 Spawn(function()PlayerMouse=Player:GetMouse()F.Button1Down:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=true})end)F.Button1Up:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=false})end)F.KeyDown:connect(function(F)InvokeServer("\075\101\121\080\114\101\115\115",{Key=F,Down=true})end)F.KeyUp:connect(function(F)InvokeServer("\075\101\121\080\114\101\115\115",{Key=F,Down=false})end)F.Move:connect(function()InvokeServer("\077\111\117\115\101\077\111\118\101",{Position=F.Hit.p,Target=F.Target})end)local T=Player:FindFirstChild("\080\108\097\121\101\114\071\117\105")if T then if UserInputService.TouchEnabled then InputCheckClone=InputCheck:Clone()InputCheckClone.InputButton.InputBegan:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=true})end)InputCheckClone.InputButton.InputEnded:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=false})end)InputCheckClone.Parent=T end end end)end function Unequipped()LocalObjects={}if InputCheckClone and InputCheckClone.Parent then InputCheckClone:Destroy()end for F,T in pairs(Animations)do if T and T.AnimationTrack then T.AnimationTrack:Stop()end end for F,T in pairs({PreventJump;ObjectLocalTransparencyModifier})do if T then T:disconnect()end end Animations={}ToolEquipped=false end function InvokeServer(F,T)pcall(function()local r=ServerControl:InvokeServer(F,T)return r end)end function OnClientInvoke(F,T)if F=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(T and(ToolEquipped and Humanoid))then SetAnimation("\080\108\097\121\065\110\105\109\097\116\105\111\110",T)elseif F=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and T then SetAnimation("\083\116\111\112\065\110\105\109\097\116\105\111\110",T)elseif F=="\080\108\097\121\083\111\117\110\100"and T then T:Play()elseif F=="\083\116\111\112\083\111\117\110\100"and T then T:Stop()elseif F=="\077\111\117\115\101\080\111\115\105\116\105\111\110"then return{Position=PlayerMouse.Hit.p,Target=PlayerMouse.Target}elseif F=="\068\105\115\097\098\108\101\074\117\109\112"then DisableJump(T)elseif F=="\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(T and ToolEquipped)then pcall(function()local F=false for r,u in pairs(LocalObjects)do if u==T then F=true end end if not F then table.insert(LocalObjects,T)if ObjectLocalTransparencyModifier then ObjectLocalTransparencyModifier:disconnect()end ObjectLocalTransparencyModifier=RunService.RenderStepped:connect(function()for F,T in pairs(LocalObjects)do if T.Object and T.Object.Parent then local F=T.Object.LocalTransparencyModifier if not T.AutoUpdate and(F==1 or F==0)or T.AutoUpdate then T.Object.LocalTransparencyModifier=T.Transparency end else table.remove(LocalObjects,F)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 = {}

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

InputCheck = Instance.new("ScreenGui")
InputCheck.Name = "InputCheck"
InputButton = Instance.new("ImageButton")
InputButton.Name = "InputButton"
InputButton.Image = ""
InputButton.BackgroundTransparency = 1
InputButton.ImageTransparency = 1
InputButton.Size = UDim2.new(1, 0, 1, 0)
InputButton.Parent = InputCheck

ToolEquipped = false

function SetAnimation(mode, value)
	if mode == "PlayAnimation" and value and ToolEquipped and Humanoid then
		local Edited = false
		for i, v in pairs(Animations) do
			if v.Animation == value.Animation then
				v.AnimationTrack:AdjustSpeed(value.Speed)
				--v.AnimationTrack:AdjustWeight(value.Weight, value.FadeTime)
				Edited = true
				break
			end
		end
		if Edited then
			return
		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 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
	Spawn(function()
		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)
		local PlayerGui = Player:FindFirstChild("PlayerGui")
		if PlayerGui then
			if UserInputService.TouchEnabled then
				InputCheckClone = InputCheck:Clone()
				InputCheckClone.InputButton.InputBegan:connect(function()
					InvokeServer("MouseClick", { Down = true })
				end)
				InputCheckClone.InputButton.InputEnded:connect(function()
					InvokeServer("MouseClick", { Down = false })
				end)
				InputCheckClone.Parent = PlayerGui
			end
		end
	end)
end

function Unequipped()
	LocalObjects = {}
	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({ PreventJump, ObjectLocalTransparencyModifier }) do
		if v then
			v:disconnect()
		end
	end
	Animations = {}
	ToolEquipped = false
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 { 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)
