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
2 years ago
Edited 2 years 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 — 2y

Answer this question