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

Stupid Question, but how to do I check if something is there?

There is a specific thing that might be in the workspace that I want to remove at the start of a server.

Will this be true if the part is there?

if game.Workspace.Brick221==true then
--stuff
end

1 answer

✓ Accepted answer

No, it won't be true since it would be the Brick!

Actually, if it's not there, it will cause an error.


We use the method FindFirstChild to find children when we don't know if they are there. Instead of erroring, they return nil:

if workspace:FindFirstChild("Brick221") ~= then

Or, since values other than false and nil are truey, we can shorten it to just:

if workspace:FindFirstChild("Brick221") then

Also this is not a stupid question! There's really only this one way to do it (due to this being the only API to do so), so if you didn't know about FindFirstChild you wouldn't have been able to come up with it.

1 comment

0

I knew about FindFirstChild and have been using it for some time, this was just a question that has always gone unanswered. Thanks

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