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

How to stop crouch animation when moving and play back when I go idle?

Asked by
TechModel 118
3 years ago
Edited 3 years ago

So I added this Local Script in StarterCharacterScripts and it works just fine, but when I walk with the crouch animation, I want it to stop playing, and make me walk casually, and when I stop, the crouch animation plays back again, until I press LeftCtrl key again. Not sure how I implement this script but I'd appreciate if I could know how to do it next time, thanks.

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Character = player.Character or player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Button = game:GetService("UserInputService")

local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://8435238978"
Animation.Parent = player.Character

local Animate
local debounce = false

Button.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.LeftControl then
        if not debounce then
            debounce = true
            Animate = Humanoid:LoadAnimation(Animation)
               Animate:Play()
        else
               Animate:Stop()
            debounce = false
       end  

 end
end)
0
Lower its priority, maybe change it from action to idle. radiant_Light203 1166 — 3y

Answer this question