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 6 years ago
Edited 6 years ago

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

for i,v in pairs(_G.PlayerTable) do
    if v ~= nil then
        print(v)-- checking
        _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
        break
    end
end

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 — 6y
0
But When I do that it says "MainScript:84: attempt to call method 'LoadCharacter' (a nil value)" MusicalDisplay 173 — 6y

1 answer

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

Answer this question