Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with this GetChildren function?

Asked by 8 years ago

I'm new to GetChildren, this is my first time using it. The script I wrote does not work, and I'm not sure why.

function boom()
    local walkwaychildren = game.Workspace.Bridge.walkway:GetChildren()
    walkwaychildren.Anchored = false
end

script.Parent.ClickDetector.MouseClick:connect(boom)

Any help?

1 answer

Log in to vote
1
Answered by
xuefei123 214 Moderation Voter
8 years ago

The function GetChildren returns a table, so you have to loop through the table.

When you loop through it, you loop through every part or object inside the GetChildren object

Here is a script for what your trying to do:

local model = game.Workspace:WaitForChild("Bridge")--Change variable
for i,v in pairs(model:GetChildren()) do
    v.Anchored = false
end 

Glad to help, if this helps please accept this answer, it gives us both rep!

0
Thanks! DrCylonide 158 — 8y
Ad

Answer this question