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

Can you use IsDescendantOf() with Strings?

Can you use IsDescendantOf() to find out if a instance is a descendant of a certain name? Like if I wanted to know if "Chair "is a decedent of something named "House"

1 answer

✓ Accepted answer

No. The argument of IsDescendantOf must be an instance.


An alternative, however, is FindFirstChild. It's a bit different, because you have to use it on the parent to find the child, but it does work with strings. If the name is found, then it returns that instance; if it's not found, it returns nil.

workspace.House:FindFirstChild("Chair")

If you're strict about what you wrote and can't make FindFirstChild work, though, you could always just write your own function to do it.

2 comments

0

Looks like I'll have to write my own function :/

0

It won't be very hard

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