I'm trying to create a function that grabs each player that specifically has a leaderstat called Alive set to true. Then I need it to print out the results to a remote to send to the players. Although, with the script I have it just prints everyones name no matter what. I'm not sure what I'm doing wrong.
Codes: PlayersModule:
function player.getPlayers()
local alive = {}
for i, v in pairs(game.Players:GetChildren()) do
if (v.leaderstats.Alive.Value == true) then
table.insert(alive,v.Name)
v.leaderstats.Points.Value = v.leaderstats.Points.Value + 25
end
end
return alive
end
Game:
if (g == 'intermission' and s == 0) then
if (game.Workspace:FindFirstChild("disaster")) then
local grabby = player.getPlayers()
local grabbytable = table.concat(grabby, ',')
returnPlayers:FireAllClients(grabbytable)
game.Workspace.disaster:Destroy()
end
LocalScript:
disaster.OnClientEvent:Connect(function(s)
disastertext.Text = s
print(s)
frame.Visible = true
wait(5)
frame.Visible = false
end)

1 comment
forgot to mention that the PlayersModule is a ModuleScript