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 make the animate script use run and walk animations based off humanoid walkspeed?

So I'm making a quick little magic game and I decided I want to add in a run/walk feature. Is there a way to do this while using the default animation script? I have already attempted to use this but the run animation kept getting clipped off by the walk one. Here's the part that I edit in the animation script:

function onRunning(speed)
	print(speed)
	if speed > 0.01 then
		pose = "Running"
		if speed <= 17 then 
			playAnimation("walk", 0.1, Humanoid)
		else
			playAnimation("run", 0.1, Humanoid)
		end
	else
		if emoteNames[currentAnim] == nil then
			playAnimation("idle", 0.1, Humanoid)
			pose = "Standing"
		end
	end
end

To clarify, I am using editing the animation script found in a character when I ran the game, and I placed it into StarterCharacterScripts once I had finished running.

1 answer

It took me a while but I figured it out myself! For those of you whom would like to know the answer, there is another line in the animate script which you will need to change as well.

The code fragment looks like this:

	elseif (pose == "Running") then
		playAnimation("walk", 0.1, Humanoid)

So all I had to do to fix this was add another pose value to my code:

function onRunning(speed)
	print(speed)
	if speed > 0.01 and speed <= 17 then
		pose = "Walking"
		playAnimation("walk", 0.1, Humanoid)
	elseif speed > 17 then
		pose = "Running"
		playAnimation("run", 0.1, Humanoid)
	else
		if emoteNames[currentAnim] == nil then
			playAnimation("idle", 0.1, Humanoid)
			pose = "Standing"
		end
	end
end

After that I edit the code fragment below it, and changed it to sense my pose value:

	elseif (pose == "Running") then
		playAnimation("run", 0.1, Humanoid)
	elseif (pose == "Walking") then
		playAnimation("walk", 0.1, Humanoid)

And presto! Clean running animation! If this helps, your welcome.

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