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

How do i find whether an object is a gui or not?

Asked by 5 years ago
Edited 5 years ago

the script i made keeps throwing errors at me and i try to fix them but it doesn't work. I'm trying to find the path to a specific text area so that people with the vip pass won't see the message. i know it sounds weird that i need to find the path to a gui i made myself, but i made it where all gui objects move into different areas (e.g. game.StarterGui.example.stuff to game.StarterGui.example.oof)

for i,v in pairs(game:GetDescendants()) do 
    if string.find(v.StateType, Text) and v.Text == "gvbadfuyhvbhdu" then
        print(v:GetFullName())
    end
end
0
Also I'd suggest not looping through all of the DataModel's descendants. If you really can't find another way to reference it then loop through just one service you know it will be in. Reset8449879 204 — 5y
0
when doing get descendants with datamodel run that code with pcall or else it may error due to RobloxLocked objects maumaumaumaumaumua 628 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

Try using the IsA Instance method or just by checking the ClassName Instance property.

Examples:

if v:IsA('GuiBase') the
    -- Do Thing
end

or

if v.ClassName == 'ScreenGui' then
    -- Do Thing
end
Ad
Log in to vote
0
Answered by 5 years ago

You can use v:IsA("ClassName") to check if v is of a certain class. In your case, your class name would be ScreenGui. If you're looking to find any textlabels, it would be TextLabel. If you don't know what the class name of something is, you can see it in the properties of said object.

Answer this question