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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
p0vd 207 Moderation Voter
4 years ago
Edited 4 years ago

Obviously the repeat wait() until not script.Parent.Parent:FindFirstChild("MenuGui") will never happen because your only looping if the MenuGuiexists. 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
0
Please accept and upvote if this helped :D p0vd 207 — 4y
Ad

Answer this question