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

How to Detect if a block does exists or not?

So Im trying to make a script that if lets say... a Part does not exist then it would print out (Part no Exist)

this was the script that I was just playing around with.

if workspace.Part then
	print("Good!")
else
	print("Bad!")
end

But the Output only says

Part is not a valid member of Workspace

Any tips?

1 answer

✓ Accepted answer

This is actually quite simple. Here's how:

if workspace:FindFirstChild("Part") then -- Detects if a part named Part is actually in workspace and detects if its nil or not
    print("Good!")
else
    print("Bad!")
end

You can read more on :FindFirstChild() here. Please accept this answer if this helped!

3 comments

0

Oh yey, How did I not think of doing this? Anyways Thanks a Bunch!

0

No problem! Can you please accept this answer then?

0

6 months of coding and still don't know how to check if a block exists, Oof

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