✓ Accepted answer
You need to loop through the players and perform the actions on each of them.
for roundtime = 30, 1, -1 do
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character and player.Character:FindFirstChild("inGame") == nil then
playersalive.Value = playersalive.Value -1
end
end
if playersalive.Value <= 1 then break end
wait(1)
text.Value = "Game time: "..roundtime
end
Hope this helped.
EDIT: Since it's taking so long, you could try having the table already present in the script so you don't have to get it each time, and see if that helps.
local players = game.Players:GetPlayers()
game.Players.PlayerAdded:connect(function(player)
players[player] = true
end)
game.Players.PlayerRemoving:connect(function(player)
if players[player] then
players[player] = nil
end
end)
for roundtime = 30, 1, -1 do
for _, player in pairs(players) do
if player.Character and player.Character:FindFirstChild("inGame") == nil then
playersalive.Value = playersalive.Value -1
end
end
if playersalive.Value <= 1 then break end
wait(1)
text.Value = "Game time: "..roundtime
end
If this doesn't work, I'm not sure; maybe someone else can answer better.
Hope this helped.
2 comments
Thank you!
No problem.