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

Any wait() command I try to use goes on forever. How is this happening?

Asked by 4 years ago
    elseif Greenify.Value >= 4 and debounce == false and debounce1 == false then
        debounce1 = true
        ChangeColors(plr, Color3.fromRGB(118, 168, 124))
        print ("Works1")

        chr.Humanoid.WalkSpeed = 0
        chr.Humanoid.JumpPower = 0 --Player can't move, going to play an animation here too later 
        print ("Works2")
        --wait(1)                              --HERE IS THE PROBLEM
        local Tree = game.ReplicatedStorage:FindFirstChild("Tree"):Clone()
        local plrposition = chr:FindFirstChild("HumanoidRootPart").Position
        local treeposition = Tree.Trunk.Position

        local newV = Vector3.new(plrposition.X, plrposition.Y - 10, plrposition.Z)
        Tree.HumanoidRootPart.Position = newV
        Tree.Parent = game.Workspace

        local loadedanimation = game.Workspace:FindFirstChild(Tree.Name).Humanoid:LoadAnimation(Tree.Trunk.Animation)
        loadedanimation:Play()
        print "Works2.3"
        --loadedanimation.Stopped:wait()   --HERE IS THE PROBLEM
        wait(0.71666666666666667407)    --This too
        Tree.HumanoidRootPart.Position = Vector3.new(newV.X, newV.Y + 10, newV.Z)
        print "Works2.6"
        print ("Works3")

        chr.Humanoid.Health = 0
        print ("Works4")
        Greenify.Value = 0
        print ("Works5")
        debounce1 = false

This is all of the code that matters but the problem is that every wait that I try to put in never works. It goes on forever and the rest of the code doesn't run. I haven't heard of anybody who has had the same issue and I don't understand why it's doing this. This is a local script and this is inside of a function if that matters.

0
I could see why the Stopped:Wait() wouldn't work (the Stopped event simply isn't fired), but the other waits should be all fine. RiskoZoSlovenska 378 — 4y
0
Also, your code is a pain to look at. Separate the elseif code into separate lines, name your variables properly and in camelCase and move the ReplicatedStorage and similar to variables declared at the top of the script. Also be consistent with how you print. RiskoZoSlovenska 378 — 4y

Answer this question