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

How can I make a running animation stop when I stop running?

Asked by 2 years ago
I'm making a survival game, and for some reason, when your stamina runs out, your running animation doesn't... this is what I'm working with, (A script in StarterPlayerScripts):
local RunAnim = script.GatherTall
local player = game.Players.LocalPlayer
local char =  player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local RunAnimTrack = hum.Animator:LoadAnimation(RunAnim)
local canSprint = false
local uis = game:GetService("UserInputService")
local animplay = game.Workspace.AnimPlay

uis.InputBegan:Connect(function(Input, gameprocess)
    if not gameprocess then
        if Input.KeyCode == Enum.KeyCode.LeftShift then
            RunAnimTrack:Play()
            animplay.Value = true
        end
    end
end)

uis.InputEnded:Connect(function(Input, gameprocess)
    if Input.KeyCode == Enum.KeyCode.LeftShift then
        RunAnimTrack:Stop()
        animplay.Value = false
    end
end)

if hum.WalkSpeed < 30 then
    RunAnimTrack:Stop()
end
Someone please help, I haven't been working on this for that long but I'm getting no errors, my code makes sense (at least to me) and my patience is running out for the animations. Could someone also show me how to make a jumping animation play while jumping, and then have the running animation continue after? Idk that would be really helpful, thanks!
0
Can you give us a little more information by giving us the picture of the placement of your script (the location) and the other things you referenced to in your script. ABDULGHANI1010 5 — 2y
0
@ABDULGHANI1010 I already said it's a local script in StarterPlayerScripts AbettrWesley 6 — 2y

Answer this question