Tool not working

Tool not working as title describes, When your equipped it should play the animation and loop and give you points, When unequipped it should stop, yet it doesnt work

local remote = game.ReplicatedStorage.RemoteEvents:FindFirstChild("Mind")
local animation = script.Parent:WaitForChild("Action")
-- Animation = https://www.roblox.com/library/4955189499/Meditating

script.Parent.Equipped:Connect(function(plr)
	animation:Play()
	local str = 3189361278316378126378216312783681273612873112312
	while wait(.2) do
        remote:FireServer(str)
    end
end)


script.Parent.Unequipped:Connect(function()
	animation:Stop()
end)

The animation should also play, how do i do this, sorry if this is basic im relatively new.

You have to load animation into the humanoid.

local remote = game.ReplicatedStorage.RemoteEvents:FindFirstChild("Mind")
local player = game.Players.LocalPlayer
--Load animation "Action" 
local animation = player.Character:WaitForChild("Humanoid"):LoadAnimation(script.Parent:WaitForChild("Action"))

-- Animation = https://www.roblox.com/library/4955189499/Meditating

script.Parent.Equipped:Connect(function(plr)
	animation:Play()
	local str = 3189361278316378126378216312783681273612873112312
	while wait(.2) do
        remote:FireServer(str)
    end
end)


script.Parent.Unequipped:Connect(function()
	animation:Stop()
end)

The tool still doesnt work

30 charssss

Is there any error in the output ? Also, could you tell what’s the use of str ?

Strength is random as its a key for an anti exploit to stop exploiters firing events, the key has to be that sent across. There is no errors in the output.

Exploiters can still look throught your code in local and send the remote event. Best way to protect your game from them is with sanity checks in the server code (Exploiters can’t access the code in serverscriptservice and serverstorage).

I think you may have misspelt game.Players at line 2, should instead be

game.Players.LocalPlayer
1 Like

Hopefully i’ve fixed your script.

local Remote = game.ReplicatedStorage.RemoteEvents:FindFirstChild("Mind")
local AnimInstance = script.Parent:WaitForChild("Action")

local plr = game.Players.LocalPlayer
local Chr = plr.Character or plr.CharacterAdded:Wait()
local hum = Chr:WaitForChild("Humanoid")

local Anim = hum:LoadAnimation(AnimInstance) -- Load the Animation into the player
local AnimPlaying = false

script.Parent.Equipped:Connect(function(plr)
	animation:Play()
AnimPlaying = true
	local str = 3189361278316378126378216312783681273612873112312

repeat
wait(0.2)
--Fire RemoteEvent here
until AnimPlaying  = false

end)


script.Parent.Unequipped:Connect(function()
AnimPlaying = false
	animation:Stop()
end)