local found = script.Parent.Parent.Parent:FindFirstChild("Ioniser") if found then script.Parent:destroy() end
In this section of code, its supposed to look in script.Parent.Parent.Parent to find a model with the name Ioniser, and if it does, its going to delete the parent of the script.
In practice, I've noticed that it will run through with the destroy() command even though "Ioniser" is not in the directory I want it to be when the script will remove itself.
Is this the proper usage of the FindFirstChild command, or should I try something else?
Make sure 'found' is false, try this
local found = script.Parent.Parent.Parent:FindFirstChild("Ioniser") print(found.Name) if found then script.Parent:destroy() elseif found == false then print("found is false") end
This is not a fix, is a debug trick, check that your variables are setted right.