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

[NOT SOLVED YET]Why isn't my custom animation playing when humanoid has higher walkspeed than 15?

Asked by
nanaluk01 247 Moderation Voter
8 years ago
Edited 8 years ago

Why isn't my custom animation playing when humanoid has higher walkspeed than 15?

So.. I created a custom character, and that is working perfectly. BUT: I managed to add a custom walking animation, then I tried adding a custom running animation that should play whenver the humanoid has a higher walkspedd than 15. I updated the animation inside "run" in the player, and changed the "run" rbxasset inside the Animate script. However, when I with my running script run, it just plays the walking animation at a faster speed.

That is when I added this to the Animate script, on the onRunning section of it to be exact.

function onRunning(speed)
    if speed > 0.01 then
        local scale = 15.0
        playAnimation("walk", 0.1, Humanoid)
        setAnimationSpeed(speed / scale)
        pose = "Running"
    elseif speed > 15 then -- I added this part, from here...
        local scale = 15.0
        playAnimation("run",0.1,Humanoid)
        setAnimationSpeed(speed / scale)
        pose = "Running" -- Till here
    else
        if emoteNames[currentAnim] == nil then
            playAnimation("idle", 0.1, Humanoid)
            pose = "Standing"
        end
    end
end

I know that I am probably doing something insanely wrong, but I can not seem to figure out what I am doing wrong.

I have searched on the Roblox Wiki without any luck at all.

How would I play my running animation while the humanoid speed is higher than 15?

By the way: I have set the default walking speed of the humanoid to lower than 15, and my running script changes it to 16.

Any help is greatly appreciated!

1 answer

Log in to vote
4
Answered by 8 years ago

15 is higher than 0.01

Perhaps consider switching your conditions around so that they don't capture eachother.

function onRunning(speed)
    if speed > 15 then
        local scale = 15.0
        playAnimation("run",0.1,Humanoid)
        setAnimationSpeed(speed / scale)
        pose = "Running" -- Till here
    elseif speed > 0.01 then
        local scale = 15.0
        playAnimation("walk", 0.1, Humanoid)
        setAnimationSpeed(speed / scale)
        pose = "Running"
    else
        if emoteNames[currentAnim] == nil then
            playAnimation("idle", 0.1, Humanoid)
            pose = "Standing"
        end
    end
end
0
That did not work unfortunately. nanaluk01 247 — 8y
0
Then the problem is more than just that code. User#6546 35 — 8y
0
Are you calling the function though? FiredDusk 1466 — 8y
0
Yes I am. nanaluk01 247 — 8y
0
All I did was that I added a small part into the 'Animate' script inside the player.. which then in return should play the animation as long as the walkspeed is over 15, then when the player stops running, in should just play my walking animation. nanaluk01 247 — 8y
Ad

Answer this question