I made a Mini Games type of game. The structure is this.
- All the maps (games) are in ServerStorage, and have a “MapScript” inside them.
- A map gets chosen, the mapscript from it gets cloned to serverscriptservice and the game is executed.
Here’s how mapscript is structured:
1. Doing a bunch of stuff, teleporting players, starting the specific game.
2. Starting a timer after which the game will end
3. Destroying the map and firing bindable event to choose next map.
Now it is very important that these mapscripts work without an error, because if there’s even a tiny error, the whole game will stop and no new maps will be chosen. I made my best to prevent errors by using if findfirstchild statements, and so far I didn’t meet any error during testing.
But better safe than sorry, so I want to do this.
local success, err = Pcall(function()
1. Doing a bunch of stuff, teleporting players, starting the specific game.
2. Starting a timer after which the game will end
end)
3. Destroying the map and firing bindable event to choose next map.
I want to do this, so that even if there is an error, the next map gets chosen and the whole game doesn’t stop.
I tried this already with one map, and it worked with no errors, then I purposefully made it error inside pcall, and again, as intended, it destroyed the error map and chose the next one. So it’s working.
My question is
Is there anything wrong with this, or something that I should consider?
This is my first time using pcalls, that’s why I need your advice. Thanks in advance.