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

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

Asked by 4 years ago
Edited 4 years ago

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?

1
Player animations should be done on the client side (local scripts) User#5423 17 — 4y
0
Please do player animations on a local script. Swinsor -3 — 4y
0
oh HomieFirePGN 137 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Did you set the Animation Priority to Action?

0
yes HomieFirePGN 137 — 4y
Ad
Log in to vote
0
Answered by
Swinsor -3
4 years ago

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

Answer this question