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

Problem with :GetChildren()? Help?

Asked by 10 years ago

Eh.. Idk what to type due to I never knew :GetChildren() is a nil on a Model... ;-;

OUTPUT : Spawns 09:03:48.262 - Workspace.Map:54: attempt to call method 'GetChildren' (a nil value) 09:03:48.263 - Stack Begin 09:03:48.264 - Script 'Workspace.Map', Line 54 - global Map 09:03:48.264 - Script 'Workspace.Map', Line 73 09:03:48.265 - Stack End

local DataTable={}
for _,a in pairs(game.Players:GetPlayers()) do
    for _,b in pairs(mv:GetChildren()) do
        if b.ClassName=='Model' and b.Name=='Spawns' then
            print(b.Name)
            for _,c in pairs(b.Name:GetChildren()) do
                print(c.Name)
                table.insert(DataTable,c.Position)
                local d=DataTable[math.random(1,#DataTable)]
                print(d)
                Teleport(d)
            end
        end
    end
end

1 answer

Log in to vote
1
Answered by 10 years ago
local DataTable={}
for _,a in pairs(game.Players:GetPlayers()) do
    for _,b in pairs(mv:GetChildren()) do
        if b.ClassName=='Model' and b.Name=='Spawns' then
            print(b.Name)
            for _,c in pairs(b:GetChildren()) do --Messed up here.
                print(c.Name)
                table.insert(DataTable,c.Position)
                local d=DataTable[math.random(1,#DataTable)]
                print(d)
                Teleport(d)
            end
        end
    end
end

The problem was that you put for _,c in pairs(b.Name:GetChildren()) do. All you need is "b" because it uses an object value, not a string value. More about :GetChilden()

0
Thank you much! MessorAdmin 598 — 10y
0
You are welcome. EzraNehemiah_TF2 3552 — 10y
Ad

Answer this question