Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

[SOLVED] Why Does My Animation Keep Stopping Every Time?

I've made a crouch script that's filtering enabled, but the animation keeps stopping

--LocalScript--
local uis = game:GetService("UserInputService")
local crouchevent = game.ReplicatedStorage.CrouchEvent
local crouchenabled = false

uis.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.C then
        if not crouchenabled then
            crouchevent:FireServer(true)
        elseif crouchenabled then
            crouchevent:FireServer(false)
        end
    end
end)
--Script--
local crouchevent = game.ReplicatedStorage.CrouchEvent

crouchevent.OnServerEvent:Connect(function(player,enabled)
    local humanoid = player.Character.Humanoid
    local crouch = humanoid:LoadAnimation(script.Crouch)
    if enabled then
        humanoid.WalkSpeed = 10
        humanoid.JumpPower = 25
        crouch.Looped = true
        crouch:Play()
        crouch:AdjustSpeed(0)
        humanoid.Running:Connect(function(speed)
            if speed > 0 then
                crouch:AdjustSpeed(1)
            elseif speed == 0 then
                crouch:AdjustSpeed(0)    
            end
        end)
    elseif not enabled then
        crouch:Stop()
        humanoid.WalkSpeed = 16
        humanoid.JumpPower = 50
    end
end)

I don't get any errors for some reason. Can anyone help?

3 comments

1

Player animations should be done on the client side (local scripts)

0

Please do player animations on a local script.

0

oh

2 answers

Ensure the length of the animation, please tell us the timeframe it is stopping and how long it should be.

This discussion is preserved as it was. New answers, comments, and votes are closed.