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

For Loops, Help Please?

Asked by
Omarstein 100
10 years ago
players = {game.Players:GetChildren()}
for i,v in ipairs(players)do
print(players[v])
end

Output: It prints "nil"

I'm not sure what I'm doing wrong, I just read about them in the wiki so if someone could help me I would appreciate it

1
Try using "pairs" instead of "ipairs" - "ipairs" is only really for tables indexed by numerical keys. duckwit 1404 — 10y
0
Thanks :) Omarstein 100 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago
for i,v in ipairs(game.Players:GetChildren()) do
print(v)
end

Okay I'm not exactly sure how to explain.. and I'm pretty sure this is not the way it should be explained, but when getting the children, you don't need to make an actual table for that.

0
Thanks :) Omarstein 100 — 10y
Ad

Answer this question