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

How can i make an animation play like its a default?

Asked by 6 years ago

i made animations like wald run etc. but how to i let them work a default for my game?

1 answer

Log in to vote
0
Answered by 6 years ago

I really do not know what you mean by "wald run" sorry. However, I understood that you made an animation and want it to play when player is running all the time I assume. It would be preferable for you to also create an idle animation (when player is not moving) but it is not neccessary. So you should create a script in ServerScriptService and write the following:

game.Players.PlayerAdded:Connect(function(player)
    local char = player.Character
    local hum = char:WaitForChild("Humanoid")
    hum.Running:Connect(function(speed)
        local anim = Instance.new("Animation")
        if speed > 0 then
            anim.AnimationId = "rbxassetid://12345" -- 12345 must be changed to your Running Animation Id
            local animTrack = hum:LoadAnimation(anim)
            animTrack:Play()
        elseif speed <= 0 then
            anim.AnimationId = "rbxassetid://12345" -- 12345 must be changed to Idle Animation Id
            local animTrack = hum:LoadAnimation(anim)
            animTrack:Play()
        end
    end)
end)

In this we have used the Running Event http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Running and the speed variable stores the speed of the player at so you can monitor it for your purposes. The elseif speed &lt;= 0 doesn't have to be included but is recommended so your game looks better

0
thx thx thx Nonglolprogames -19 — 6y
0
ok can you please say that this answer is accepted DumbKickButt5588 167 — 6y
Ad

Answer this question