Error: Workspace.GameManager.Findwinner:6: attempt to concatenate nil with string
Code:
1 | while true do |
2 | wait() |
3 | local alive = game.Teams.Survivors:GetPlayers() |
4 | if script.Parent.PlayersLeft.Value = = 1 then |
5 | local name = alive.Name |
6 | script.Parent.GameStatus.Value = name .. "won the game!" |
7 | end |
8 | end |
You're getting a table, and trying to see the name of it.
1 | while true do |
2 | wait() |
3 | local alive = game.Teams.Survivors:GetPlayers() |
4 | if script.Parent.PlayersLeft.Value = = 1 then |
5 | local name = alive [ 1 ] .Name |
6 | script.Parent.GameStatus.Value = name .. "won the game!" |
7 | end |
8 | end |
I'm pretty sure this is the solution.
I ended up just using a different strategy with for I, v in pairs technique. AND IT WORKED.
01 | while true do |
02 | wait() |
03 |
04 | if script.Parent.PlayersLeft.Value = = 1 then |
05 | local teams = game:GetService( 'Teams' ) |
06 |
07 | for _, player in pairs (teams [ 'Survivors' ] :GetPlayers()) do |
08 | print (player.Name) |
09 | end |
10 | end |
11 | end |