When creating a plugin and including an if statement to check if a part exists in workspace it just errors.
If the Part exists it will not error. But if it does not it errors. This doesn’t make any sense. Any help?
When creating a plugin and including an if statement to check if a part exists in workspace it just errors.
If the Part exists it will not error. But if it does not it errors. This doesn’t make any sense. Any help?
Could you post the code that gives you the error?
Does the code use FindFirstChild
? FindFirstChild
returns nil
instead of throwing an error if the child instance you’re trying to find doesn’t exist.
if workspace:FindFirstChild("whatever") then
-- ...
end
-- or:
local whatever = workspace:FindFirstChild("whatever")
if whatever then
-- ...
end