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

Is this the way to use :GetChildren()?

I barely use :GetChildren() so yeah...

x = script.Parent:GetChildren("script.Parent.Fire")
x.Enabled = false

---I dont get it....

1 answer

✓ Accepted answer

:GetChildren() returns a table you can iterate through.

In the case you just attempted, you should use the FindFirstChild function, which returns a child with the specified name.

x = script.Parent:FindFirstChild("Fire")
x.Enabled = false

Here is a list of all functions that can be used on Instances.

To use :GetChildren(), most people do like so:

for index, value in pairs(script.Parent:GetChildren()) do 
	value:Destroy()
end

In the above script, GetChildren() returns a table the for loop can iterate through, then perform tasks for each one.

GetChildren is generally only used if you need to perform an object to several objects. Otherwise you can use FindFirstChild, or WaitForChild.

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