Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I change a player's animations for a limited time?

I'm trying to play an animation every time a player is running, in a limited time. I've already tried to use something like this

local humanoid = script.Parent:WaitForChild("Humanoid")
local anim = script.Animation
local animTrack = humanoid:LoadAnimation(anim)

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		animTrack:Play()
	else
		animTrack:Stop()
	end
end)

in StarterCharacterScripts, and also altered it a bit to use in StarterPlayerScripts, but it didn't work. What's wrong?

3 comments

0

You're attempting to interfere with a player's input to run. That's the problem.

0

But how is it interfering?

0

If they input any key in the WASD or arrow key sequence, they can easily bust out of the animation. In order to fix this, you have to keybind the movement keys to different keys.

1 answer

Here

local humanoid = script.Parent:WaitForChild("Humanoid")
local anim = script.Animation
local animTrack = humanoid:LoadAnimation(anim)
while true do
wait(0.001) 
humanoid.Running:Connect(function(speed)
    if speed > 0 then
        animTrack:Play()
   else
        animTrack:Stop()
    end
   end
end)

its that work?

1 comment

0

no

This discussion is preserved as it was. New answers, comments, and votes are closed.