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

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

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

2 comments

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.

0

when doing get descendants with datamodel run that code with pcall or else it may error due to RobloxLocked objects

2 answers

✓ Accepted answer

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

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.

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