You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
When a player clicks the button, this code gets executed to damage the player:
RS.Remotes.GameLogic.ClientDamage.OnServerEvent:Connect(function(player,dmgPlr)
local damagedSession = Sessions.SESSIONS[dmgPlr]
print(dmgPlr,Sessions.SESSIONS)
print(damagedSession)
damagedSession:SetHealth(damagedSession.lives - 1)
Sessions:BroadcastLives()
end)
however when the line executes, damagedSession returns nil and next lines error.
I literally cannot comprehend why this errors because it works prior to players leaving. I had 3 players in the server (Player 1 to ID 1 and etc). Player 1 and 3 leaves, leaving only Player 2 with ID 2. Their data remains in Sessions.SESSIONS in index 2. Yet when I try to get it the table returns nil??