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

How to check if a Gui/Variable exists?

Asked by 5 years ago

(before I start i want to let you know this is really long) I was making a game about the UTG (ultimate trolling gui). It is basically a testing zone that will let you do any command from the GUI. But when I click on the "R6" button (makes your character r6 so it can load the utg) a little button pops up at the top and it says "Original Game". I can't find where it comes from as it is not in the r6 script and I can't find it in the GUI itself. I did some research and looked at a plugin that was required in the r6 script but it was just a script that combined the joints and made your character r6. When you clicked on the Original Game button it would teleport you to another game. I made a script that was supposed to remove it whenever it pops up, but i'm having a problem. The script says

1playerGui.Rejoin:Remove() --playerGUI is a variable i made and Rejoin is the name of the GUI that keeps bugging me

but it isn't working. I think a script that checks if the "Rejoin" button exists and removes it if it does would work, but I don't know how to check if an item exists. Here is the original script:

1local playerGui = script.Parent.Parent
2playerGui.Rejoin:Remove()

(sorry for the long the backstory, and i dont know how to describe the thing that should be removed)

0
I should also mention i looked up some variables i have never used in a script and those didnt help either. I'm not that intelligent. AbsurdAwesome101 56 — 5y
0
You want to check if this gui thats bugging you exists, right? marine5575 359 — 5y
0
Did it give you an error? marine5575 359 — 5y
0
nope, it didnt. and yes, I want to see if it exists. AbsurdAwesome101 56 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You could try this:

script

01local playerGui = script.Parent.Parent
02local playerGuiParent = playerGui.Parent
03local originalgame = playerGuiParent:FindFirstChild("[change-to-name]") -- the name of the "original game" gui also finds the first child of this name
04if originalgame then
05    print("It exists!")
06    originalgame:Destroy()
07    print("now it doesn't :D")
08    return -- just so it doesn't go to the other one
09end
10else
11    print("It doesn't exist!")
12end
Ad

Answer this question