local runService = game:GetService("RunService")
local stopped = {} --a table so you can add as much as you want!
local isPlaying = {} --a table so you can add as much animations as you want, same as before.
function handle(animation)
if table.find(stopped , animation.Name) then return end
if not table.find(isPlaying , animation.Name) then
animation:Play() --check capitalization...
table.insert(isPlaying , animation.Name)
animation.Stopped:Connect(function()
table.remove(isPlaying , table.find(isPlaying , animation.Name))
end)
end
end
runService.renderStepped:Connect(function()
--your animation.looped = false
--handle(your animation)
--add it to the stopped table to stop it from playing and remove it so it continues.
end)
To stop it add it to the stopped table and remove it to continue, read whats written inside the renderStepped, i explained everything, the function will just handle the whole animating part
im sorry im really slow today…
i get that youd use the function “handle”… but i dont get how to add it to the table, would I just add it into those brackets? is there anyway i could add them in with a line of code so i could do that on the unequipped event?
Just use handle(animation) once in the script, if you want it to fully stop the animation from working, add it to the table after you call the function
okay okay,
so to run an animation once, you run handle(animation) in the script, to loop the animation you would add it to the table but then remove it, and to stop the loop you would just keep it on the table?
Yes exactly but if you want it to try running until its playable, have the handle(animation) inside the render stepped function and the adding / removing from outside.
All you really need to do here is initialize truck outside of the tool.Equipped function. That way you can reference it in tool.Unequipped and call :Stop() on it like you did
Edit: Initialize just means create the variable and assign a value to it