Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ServerScriptService.Main:77: attempt to concatenate field '?' (a nil value)?

Asked by
R_alatch 394 Moderation Voter
6 years ago
Edited 6 years ago

My code works fine until I get to line 8, and it gives the error shown above. I have no idea how to fix this, and any help is appreciated. Please note this is not the full code.

for _, player in pairs(activecontestants) do
        if player and player.Character then
            local humanoid = player.Character:FindFirstChild("Humanoid")
            if humanoid then
                humanoid:UnequipTools()
                player.Backpack:ClearAllChildren()
                humanoid.Health = 100
                gameState.Value = "The winner(s) are " .. activecontestants[player.Name]
                local lobbyspawns = workspace:FindFirstChild("LobbySpawns"):GetChildren()
                player.Character:MoveTo(lobbyspawns[math.random(1, #lobbyspawns)].Position)
            end
        end
    end
end
0
Only strings can be concatenated. just read the error. cabbler 1942 — 6y
0
activecontestants[player.Name] might be nil. Try putting "print(activecontestants[player.Name] )" just before the line that errors, to see what you're trying to concat. whenallthepigsfly 541 — 6y

Answer this question