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

Find First Child Usage?

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?

1 answer

✓ Accepted answer

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.

2 comments

0

esleif lol

0

:|

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