Hello! I’m currently in the process of writing a round system for my PVP game.
It’s going great so far but I do have one concern.
There’s no way I can allow my rounds script to error because that would effectively cause the whole game to break.
My rounds script handles a lot of the players by adding instances, moving characters CFRame and so on. Since any of these players could choose to leave the game at any moment I need to confirm that they are still in the server. I was thinking of just pcalling a lot of my operations but I figured that’s just a rubberband solution to this issue.
So, what I need to know is whether I can trust the player instance to always exist in a scenario like this:
for _, player in pairs(players) do
if not player then return end
-- Player leaves here as an example
-- Can I be sure that this instance under player remains?
-- Or would I need to always check for it?
player.test.Value = 2
end
- In this loop is there any way that a player could leave and the code therefore errors?
- Can I be sure that all instances I have under the player is there until it’s fully removed?
Thanks in advance for any responses.