I have a custom walk and run animation set for the player and a sprint script that just sets the speed of the player when shift key is pressed.
walk = {
{ id = "http://www.roblox.com/asset/?id=17485591868", weight = 10 }
},
run = {
{ id = "http://www.roblox.com/asset/?id=17485593806", weight = 10 }
},
(i changed the animate script from the character)
The walking animation is always used, regardless of speed, even if there is a running animation. At the beginning I just wanted to load animations and play them when the player is running, but the animation plays when the player is standing, jumping and I would have to do a lot of checks, and I wanted to keep everything simple.
Is there any way to switch which of these animations will be used?
Im pretty sure roblox had already built in automatically this stuff for r15 maybe, dont know about r6, you just replace the animation for run and change the tranform speed trigger somewhere in script
i tried to modify the code from Animate that plays the animation when the player is running but run animation still isnt playing and weird things happen when character jumps
function onRunning(speed)
speed /= getRigScale()
if speed > 0.01 and speed <= 8 then -- Walk anim should play (speed 8)
playAnimation("walk", 0.1, Humanoid)
if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=17485591868" then
setAnimationSpeed(speed / 14.5)
end
pose = "Running"
elseif speed > 8 then -- Run anim should play (speed 24)
playAnimation("run", 0.1, Humanoid)
if currentAnimInstance and currentAnimInstance.AnimationId == "http://www.roblox.com/asset/?id=17485593806" then
setAnimationSpeed(speed / 14.5)
end
else
if emoteNames[currentAnim] == nil then
playAnimation("idle", 0.1, Humanoid)
pose = "Standing"
end
end
end