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

For Loops, Help Please?

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

2 comments

1

Try using "pairs" instead of "ipairs" - "ipairs" is only really for tables indexed by numerical keys.

0

Thanks :)

1 answer

✓ Accepted answer
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.

1 comment

0

Thanks :)

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