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
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
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
I knew about FindFirstChild and have been using it for some time, this was just a question that has always gone unanswered. Thanks