Tool=script.Parent Handle=Tool:WaitForChild("\072\097\110\100\108\101")Players=game:GetService("\080\108\097\121\101\114\115")Debris=game:GetService("\068\101\098\114\105\115")RunService=game:GetService("\082\117\110\083\101\114\118\105\099\101")ContentProvider=game:GetService("\067\111\110\116\101\110\116\080\114\111\118\105\100\101\114")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"InputFrame=Instance.new("\070\114\097\109\101")InputFrame.Name="\073\110\112\117\116\066\117\116\116\111\110"InputFrame.BackgroundTransparency=1 InputFrame.Size=UDim2.new(1,0,1,0)InputFrame.Parent=InputCheck RbxUtility=LoadLibrary("\082\098\120\085\116\105\108\105\116\121")Create=RbxUtility.Create 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")Rate=.016666666666667 ToolEquipped=false function SetAnimation(Y,n)if not ToolEquipped or not CheckIfAlive()then return end if Y=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and(n and(ToolEquipped and Humanoid))then for Y,o in pairs(Animations)do if o.Animation==n.Animation then o.AnimationTrack:Stop()table.remove(Animations,Y)end end local Y=Humanoid:LoadAnimation(n.Animation)table.insert(Animations,{Animation=n.Animation,AnimationTrack=Y})Y:Play(n.FadeTime,n.Weight,n.Speed)elseif Y=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and n then for Y,o in pairs(Animations)do if o.Animation==n.Animation then o.AnimationTrack:Stop()table.remove(Animations,Y)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(Y)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()Y.Button1Down:connect(function()InvokeServer("\066\117\116\116\111\110\049\067\108\105\099\107",{Down=true})end)Y.Button1Up:connect(function()InvokeServer("\066\117\116\116\111\110\049\067\108\105\099\107",{Down=false})end)Y.KeyDown:connect(function(Y)InvokeServer("\075\101\121\080\114\101\115\115",{Key=Y,Down=true})end)Y.KeyUp:connect(function(Y)InvokeServer("\075\101\121\080\114\101\115\115",{Key=Y;Down=false})end)local n=Player:FindFirstChild("\080\108\097\121\101\114\071\117\105")if n then InputCheckClone=InputCheck:Clone()if UserInputService.TouchEnabled then InputCheckClone=InputCheck:Clone()InputCheckClone.InputButton.InputBegan:connect(function()InvokeServer("\066\117\116\116\111\110\049\067\108\105\099\107",{Down=true})end)InputCheckClone.InputButton.InputEnded:connect(function()InvokeServer("\066\117\116\116\111\110\049\067\108\105\099\107",{Down=false})end)InputCheckClone.Parent=n end end for Y,n in pairs(Tool:GetChildren())do if n:IsA("\065\110\105\109\097\116\105\111\110")then ContentProvider:Preload(n.AnimationId)end end end)end function Unequipped()for Y,n in pairs(Animations)do if n and n.AnimationTrack then n.AnimationTrack:Stop()end end if InputCheckClone then Debris:AddItem(InputCheckClone,0)end if ObjectLocalTransparencyModifier then ObjectLocalTransparencyModifier:disconnect()end LocalObjects={}Animations={}ToolEquipped=false end function InvokeServer(Y,n)local o=nil pcall(function()o=ServerControl:InvokeServer(Y,n)end)return o end function OnClientInvoke(Y,n)if not ToolEquipped or not CheckIfAlive()then return end if Y=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and n then SetAnimation("\080\108\097\121\065\110\105\109\097\116\105\111\110",n)elseif Y=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and n then SetAnimation("\083\116\111\112\065\110\105\109\097\116\105\111\110",n)elseif Y=="\080\108\097\121\083\111\117\110\100"and n then n:Play()elseif Y=="\083\116\111\112\083\111\117\110\100"and n then n:Stop()elseif Y=="\077\111\117\115\101\068\097\116\097"then return PlayerMouse and{Hit=PlayerMouse.Hit;Target=PlayerMouse.Target}or nil elseif Y=="\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(n and ToolEquipped)then pcall(function()local Y=false for o,C in pairs(LocalObjects)do if C==n then Y=true end end if not Y then table.insert(LocalObjects,n)if ObjectLocalTransparencyModifier then ObjectLocalTransparencyModifier:disconnect()end ObjectLocalTransparencyModifier=RunService.RenderStepped:connect(function()for Y,n in pairs(LocalObjects)do if n.Object and n.Object.Parent then if not n.AutoUpdate and(n.Object.LocalTransparencyModifier==1 or n.Object.LocalTransparencyModifier==0)or n.AutoUpdate then n.Object.LocalTransparencyModifier=n.Transparency end else table.remove(LocalObjects,Y)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")
Debris = game:GetService("Debris")
RunService = game:GetService("RunService")
ContentProvider = game:GetService("ContentProvider")
UserInputService = game:GetService("UserInputService")

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

RbxUtility = LoadLibrary("RbxUtility")
Create = RbxUtility.Create

Animations = {}
LocalObjects = {}

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

Rate = (1 / 60)

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()
				table.remove(Animations, i)
			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("Button1Click", { Down = true })
		end)
		Mouse.Button1Up:connect(function()
			InvokeServer("Button1Click", { 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)
		local PlayerGui = Player:FindFirstChild("PlayerGui")
		if PlayerGui then
			InputCheckClone = InputCheck:Clone()
			if UserInputService.TouchEnabled then
				InputCheckClone = InputCheck:Clone()
				InputCheckClone.InputButton.InputBegan:connect(function()
					InvokeServer("Button1Click", { Down = true })
				end)
				InputCheckClone.InputButton.InputEnded:connect(function()
					InvokeServer("Button1Click", { Down = false })
				end)
				InputCheckClone.Parent = PlayerGui
			end
		end
		for i, v in pairs(Tool:GetChildren()) do
			if v:IsA("Animation") then
				ContentProvider:Preload(v.AnimationId)
			end
		end
	end)
end

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

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

function OnClientInvoke(mode, value)
	if not ToolEquipped or not CheckIfAlive() 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 ((PlayerMouse and { Hit = PlayerMouse.Hit, Target = PlayerMouse.Target }) or nil)
	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

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