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

How to show (crouch) animation immediately?

Asked by 6 years ago

Hey! I need bit of help here, I made a script and specific animations (CrouchIdle & CrouchWalk) which work pretty well, but the thing is, when player starts to hold shift it shows him default idle animation, any ideas how to fix this and show crouchidle immediately? (Same on standing up)

local plr = game.Players.LocalPlayer
local char = script.Parent

local i = script.idle
local w = script.walk
local idle = char.Humanoid:LoadAnimation(i)
local walk = char.Humanoid:LoadAnimation(w)

local IS = game:GetService("UserInputService")

IS.InputBegan:connect(function(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.LeftShift then
        idle:Play()
        char.Animate.run.RunAnim.AnimationId = "rbxassetid://1244608012"
        char.Animate.idle.Animation1.AnimationId = "rbxassetid://1244592526"
        char.Animate.idle.Animation2.AnimationId = "rbxassetid://1244592526"
    end
end)

IS.InputEnded:connect(function(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.LeftShift then
        char.Animate.run.RunAnim.AnimationId = "rbxassetid://507767714"
        char.Animate.idle.Animation1.AnimationId = "rbxassetid://507766388"
        char.Animate.idle.Animation2.AnimationId = "rbxassetid://507766666"
        char.Humanoid:LoadAnimation(char.Animate.idle.Animation2):Play()
        char.Humanoid.Running:connect(function(run)
            char.Humanoid:LoadAnimation(char.Animate.run.RunAnim):Play()
        end)
    end
end)

--507766388 507766666 507767714

Answer this question