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

Get the rest of the players

local rp = gt[math.random(1,#gt)]

So now i have the random player, but how do i get the rest of them? I want everyone else than the random player

2 answers

✓ Accepted answer

If you want everyone other then 1 player it would be somewhat like this,

for _,Player in pairs(gt) do -- For all the players
	if not Player == rp then -- If player is not the randomly selected player
		--Etc.
	end
end

or if you wanted them to be in a table,

local OtherPlayers = {}
for _,Player in pairs(gt) do
	if not Player == rp then
		table.insert(OtherPlayers, Player)
	end
end

'OtherPlayers' now has every player but your random one.

1 comment

0

But @Frostftw could you make that if everyone else than that random player have their health to 0 then it would disable a script? could you make that

for i, v in pairs(gt) do
	if v == rp then
		gt:remove(i)
		break
	end
end

Now, gt only contains unselected players.

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