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 4 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

playerGui.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:

local playerGui = script.Parent.Parent
playerGui.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 — 4y
0
You want to check if this gui thats bugging you exists, right? marine5575 359 — 4y
0
Did it give you an error? marine5575 359 — 4y
0
nope, it didnt. and yes, I want to see if it exists. AbsurdAwesome101 56 — 4y

1 answer

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

You could try this:

script

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

Answer this question