Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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?

0
You're attempting to interfere with a player's input to run. That's the problem. DeceptiveCaster 3761 — 5y
0
But how is it interfering? AradIsHere 2 — 5y
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. DeceptiveCaster 3761 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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?

0
no AradIsHere 2 — 5y
Ad

Answer this question