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

Why wont this animation play?

Asked by
Chronomad 180
8 years ago

This script should be playing an animation based on whether Stance.Value = right or left. It plays the cooresponding animation for 'left' but not for right. It's strange. Any help is appreciated.

    --Player Values
    local move_left = false
    local move_right = false
    local already_ran = false
    local grounded = false
    local idleAnimation = Instance.new("Animation")
    idleAnimation.AnimationId = "rbxassetid://317651678"
    local runningAnimation = Instance.new("Animation")
    runningAnimation.AnimationId = "rbxassetid://319211805"
    local R2 = Instance.new("Animation")
    R2.AnimationId = "rbxassetid://319228239"
    --local I2 = Instance.new("Animation")
    --I2.AnimationId = "rbxassetid://319228239"


    function playAnimation(parent)
        local AnimTrack = player.Character.Humanoid:LoadAnimation(parent)
        AnimTrack:Stop()
        wait(.1)
        AnimTrack:Play()
    end

    function onGround(speed)
        if grounded == false then
            grounded = true
        end
        if speed > 1 and player.PlayerGui.SwordPlaySystem.Stance.Value == ("Left") then -- This one works
            if already_ran == false then
                already_ran = true
                playAnimation(runningAnimation)

                elseif  speed > 1 and player.PlayerGui.SwordPlaySystem.Stance.Value == ("Right") -- this one doesn't 
        then
                    if already_ran == false then
                        already_ran = true
                        playAnimation(R2)
                end 
            end 
        else
            already_ran = false
            playAnimation(idleAnimation)
        end
    end

end
0
what type of scirpt is it in koolkid8099 705 — 8y

1 answer

Log in to vote
2
Answered by
Decemus 141
8 years ago

Ah, just a small mistake. The elseifcode is running under the wrong if statement. Simply fix this by adding an end before the elseif of Stance.Value == ("Right")

1
He's right. dirty_catheter 7 — 8y
0
Wooh! Thanks alot c: Chronomad 180 — 8y
Ad

Answer this question