GUI Instantly Reappearing

Well, this marks an hour trying to debug this. If I don’t ask for help, I’ll likely go insane.

So, I’ve been trying to code a GUI that creates a ScrollingFrame, and you select from a bunch of TextButtons, which assigns a value to a StringValue. I detect when the StringValue is changed, and close the options menu (which happens when the text button is clicked using the following:

repeat wait() until script.Parent.Selected.Changed

I assign values to the StringValue using the following:

for i, playerGame in pairs (playerGames) do
		local frame ="Frame", gamesFrame.Options)
		local textButton ="TextButton", frame)
		textButton.Name = playerGame
		textButton.Text = playerGame
			script.Parent.Selected.Value = textButton.Text

Yet every time I click to open the options, the window auto closes. I’ve tried not regestering these until there are new inputs, which has failed. I tried using :GetPropertyChangedSignal(), which has also failed. No error messages, I’ve tried printing the new value and it hasn’t changed. I’m 100% stumped.

Any, and I mean ANY, help is appreciated :smile: !

Have you tried having the gui made already and have it in ReplicatedStorage and make it visible through the loop?

1 Like

Your current code will never wait for changed to fire, because all you’re doing is waiting until “Changed” exists, which it always does. Also, repeat wait() loops are generally bad practice.

If you need to wait until the Changed event is fired you can just do script.Parent.Selected.Changed:Wait(). Also, a better approach would be to use GetPropertyChangedSignal so the event only fires when a certain property gets changed, such as “Value”

1 Like

This, or simply use a function utilizing the changed event

    --do stuff

but if its a one time event then I would use the Wait() yeah