Hey, everyone!
I’m working on a sprinting feature for my game. The sprinting feature already works, but I want a running animation to play whenever the player starts sprinting, and to stop when their stanima runs out.
So far I have an idle animation and a walking animation playing, and this is the script I used for that-
local character = script.Parent
local humanoid = character:WaitForChild(“Humanoid”)
local walkAnim = script:WaitForChild(“Walk”)
local walkAnimTrack = humanoid.Animator:LoadAnimation(walkAnim)
local idleAnim = script:WaitForChild(“Idle”)
local idleAnimTrack = humanoid.Animator:LoadAnimation(idleAnim)
humanoid.Running:Connect(function(speed)
if speed > 0 then
if not walkAnimTrack.IsPlaying and idleAnimTrack.IsPlaying then
idleAnimTrack:Stop()
walkAnimTrack:Play()
end
else
if walkAnimTrack.IsPlaying and not idleAnimTrack.IsPlaying then
idleAnimTrack:Play()
walkAnimTrack:Stop()
end
end
end)
idleAnimTrack:Play()
Is there any way I could do this? (Also, I’m not sure if this is important or not, but the character the player is going to be playing as is a custom model, not R15 or R6)