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

How do I make the other part of the script execute after these if statements?

Asked by 4 years ago

Heres my code:

for _, structureButton in pairs(StructureFrame:GetChildren()) do
    if structureButton:IsA("TextButton") then
        structureButton.MouseButton1Up:Connect(function()

            if structureButton.Name == "WoodWall" then
                if game.Players.LocalPlayer.Materials.Wood.Value >= 5 then
                    game.Players.LocalPlayer.Materials.Wood.Value = game.Players.LocalPlayer.Materials.Wood.Value - 5
                else
                    script.Parent.NotEnoughMats.Visible = true
                    wait(3)
                    script.Parent.NotEnoughMats.Visible = false
                    return
                end
            else
                if game.Players.LocalPlayer.Materials.Stone.Value >= 5 then
                    game.Players.LocalPlayer.Materials.Stone.Value = game.Players.LocalPlayer.Materials.Stone.Value - 5
                else
                    script.Parent.NotEnoughMats.Visible = true
                    wait(3)
                    script.Parent.NotEnoughMats.Visible = false
                    return
                end
            end

            -- ******This doesnt execute after the if statements
            script.Parent.Cancel.Visible = true
            StructureFrame.Visible = false

(Read the -- part of the code)

1 answer

Log in to vote
0
Answered by 4 years ago

Return ends the loop, so I’m guessing those return things are the problem. Try deleting them and running it again, and check your if parameters

0
Does the same thing. Nothing happened when i removed the return Recrucity 13 — 4y
0
Try putting print statements at places in your code to see where the code stops to better understand the situation and issue iamtryingtofindname 22 — 4y
Ad

Answer this question