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

My gui = nil but my script is coming back with a nil value?

I'm making a script so that when a certain gui is destroyed then another one will appear but it's not working.

Here is my script

while script.Parent.Parent.MenuGui do
	repeat wait() until not script.Parent.Parent:FindFirstChild("MenuGui")
	if not script.Parent.Parent:FindFirstChild("MenuGui") then
		break
	end
end

script.Parent.Enabled = true

1 answer

✓ Accepted answer

Obviously the repeat wait() until not script.Parent.Parent:FindFirstChild("MenuGui") will never happen because your only looping if the MenuGui exists. You should only loop if MenuGui does NOT exist.

This is the correct way of your code:

while not script.Parent.Parent.MenuGui do
   break
end

script.Parent.Enabled = true

1 comment

0

Please accept and upvote if this helped :D

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