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

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

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

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

5 comments

0

That did not work unfortunately.

0

Then the problem is more than just that code.

0

Are you calling the function though?

0

Yes I am.

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.

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