ClientControl.OnClientInvoke=function(u,t)if u=="\080\108\097\121\065\110\105\109\097\116\105\111\110"and Humanoid then for u,P in pairs(Animations)do if P.Animation==t.Animation then P.AnimationTrack:Stop()table.remove(Animations,u)end end local u=Humanoid:LoadAnimation(t.Animation)table.insert(Animations,{Animation=t.Animation;AnimationTrack=u})u:Play(t.FadeTime,t.Weight,t.Speed)elseif u=="\083\116\111\112\065\110\105\109\097\116\105\111\110"and t then for u,P in pairs(Animations)do if P.Animation==t.Animation then P.AnimationTrack:Stop()table.remove(Animations,u)end end elseif u=="\080\114\101\108\111\097\100"and t then ContentProvider:Preload(t)elseif u=="\080\108\097\121\083\111\117\110\100"and t then t:Play()elseif u=="\083\116\111\112\083\111\117\110\100"and t then t:Stop()elseif u=="\077\111\117\115\101\080\111\115\105\116\105\111\110"then return PlayerMouse.Hit.p end end function InvokeServer(u,t)pcall(function()local P=ServerControl:InvokeServer(u,t)return P end)end function CheckIfAlive()return Player and(Player.Parent and(Humanoid and(Humanoid.Parent and Humanoid.Health>0)))end function Equipped(u)Character=Tool.Parent Player=Players:GetPlayerFromCharacter(Character)Humanoid=Character:FindFirstChild("\072\117\109\097\110\111\105\100")if not CheckIfAlive()then return end PlayerMouse=Player:GetMouse()u.Button1Down:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=true})end)u.Button1Up:connect(function()InvokeServer("\077\111\117\115\101\067\108\105\099\107",{Down=false})end)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()for u,t in pairs(Animations)do if t and t.AnimationTrack then t.AnimationTrack:Stop()end end Animations={}end Tool.Equipped:connect(Equipped)Tool.Unequipped:connect(Unequipped)


ClientControl.OnClientInvoke = (function(Mode, Value)
	if Mode == "PlayAnimation" 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
	elseif Mode == "Preload" and Value then
		ContentProvider:Preload(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
	end
end)

function InvokeServer(Mode, Value)
	pcall(function()
		local ServerReturn = ServerControl:InvokeServer(Mode, Value)
		return ServerReturn
	end)
end

function CheckIfAlive()
	return (Player and Player.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0)
end

function Equipped(Mouse)
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChild("Humanoid")
	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()
	for i, v in pairs(Animations) do
		if v and v.AnimationTrack then
			v.AnimationTrack:Stop()
		end
	end
	Animations = {}
end

Tool.Equipped:connect(Equipped)
Tool.Unequipped:connect(Unequipped)
