I am trying to make a game where you collect candies, and when you touch them, you stop moving and run an animation to collect the candy. I've managed to make the animation and spawn candies, but I looked everywhere and every solution I've tried to make the player stop moving didn't work.
What do I need to add to this script that belongs to the candies (parts) to make the player stop moving, and when the animation is done, let the player move again? (the script is working)
local Anim = script.Parent.GetCandy
local debounce = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true
local AnimTrack = hit.Parent.Humanoid:LoadAnimation(Anim)
AnimTrack:Play()
wait(.9)
script.Parent:Destroy()
wait(1.6)
debounce = false
end
end)

5 comments
The only thing is the wait() functions are to make the candy disappear in the middle of the animation, but this will do it.
It seems as the animation never stopped, so I'm stuck in place. Sorry for late response
You probably have the animation on a loop. Check the setting in the Animation Editor. I've also tested this with a non-looping anim too.
It's not on a loop, believe me. It seems like the animation "never ends" so the speed never gets changed back.
So I just brought back the wait()'s.