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

Can somebody help with this easy problem?

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?

2 comments

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.

0

But When I do that it says "MainScript:84: attempt to call method 'LoadCharacter' (a nil value)"

1 answer

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

1 comment

0

thank you very much

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