game.OnClose function - how do disable for studio?

How can I make the Game.OnClose function not work in studio, but only on an actual server. When I click the stop button, it stalls the entire studio for that 10 seconds it takes to save the player’s data. I would like this to only work on a real server and have it disabled in studio. Is there any way to do so? (like detecting if its a studio test or not)

Check game:GetService(“RunService”):IsStudio().

6 Likes

You always reply to threads quickly, you are very helpful.

5 Likes