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

How do I set a "If" condition to detect when a member is not a valid member of something?

Asked by 6 years ago

If a part is not a valid member of workspace for example, how would I set the "If" condition for it to then do something when it detects that?

1 answer

Log in to vote
0
Answered by
Elixcore 1337 Moderation Voter
6 years ago
Edited 6 years ago
part = workspace:WaitForChild("Part")

if not part then

end

or you could also do this

if not workspace:FindFirstChild("Part") then

end
0
Roblox errors if you attempt to index a nonexistent object directly. In the first code segment you would also need to use FindFirstChild() dyler3 1510 — 6y
0
sorry Elixcore 1337 — 6y
Ad

Answer this question