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

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

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

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

2 comments

0

Does the same thing. Nothing happened when i removed the return

0

Try putting print statements at places in your code to see where the code stops to better understand the situation and issue

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