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

Crouch script bobs up and down insteaf of toggling down?

Asked by
zomspi 541 Moderation Voter
1 year ago
Edited 1 year ago

Basically I click C and it kinda bobs, what is meant to happen is it toggles, so I click c once and it crouches, then I tap it again and it uncrouches, what is happening?

local UIS = game:GetService("UserInputService")

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animator = Character:WaitForChild("Humanoid")

local isCrouching = false

local IdleAnim

UIS.InputBegan:Connect(function(Input, Chatted)
    if not Chatted then 
        if Input.KeyCode == Enum.KeyCode.C then
            if isCrouching == false then 
                print("Crouching")
                IdleAnim = Animator:LoadAnimation(script:WaitForChild("Animation"))
                isCrouching = true
                IdleAnim:Play()
            else
                print("Not Crouching")
                isCrouching = false
                IdleAnim:Stop()
            end
    end
    end
end)


Here is a video of what is happening with console print statements: https://streamable.com/badz6t

0
I fixed it by changign the animations zomspi 541 — 1y

Answer this question