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

Can somebody help with this easy problem?

Asked by 7 years ago
Edited 7 years ago

Pretty simple.. I have this for do in pairs loop:

1for i,v in pairs(_G.PlayerTable) do
2    if v ~= nil then
3        print(v)-- checking
4        _G.PlayerTable[v]:LoadCharacter()-- I want to respawn all the players in the table here, I didn't know what to do so i put that lol its wrong
5        break
6    end
7end

I'm trying to reference all the players inside of my table, but I don't know how.

Can somebody show me what i'm doing wrong?

0
Since you're looping through each value in the table, you can just do "v:LoadCharacter()" However, the break will make it so that it only loads one player since it breaks the loop so you can just remove the break. Ultimate_Piccolo 201 — 7y
0
But When I do that it says "MainScript:84: attempt to call method 'LoadCharacter' (a nil value)" MusicalDisplay 173 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago
1for i,v in pairs(_G.PlayerTable) do
2    if v ~= nil then
3        print(_G.PlayerTable[i])
4    game:GetService("Players"):WaitForChild(_G.PlayerTable[i]):LoadCharacter()
5    end
6end
0
thank you very much MusicalDisplay 173 — 7y
Ad

Answer this question