Advanced Shutdown Script

Hey! So I have known this for a while now but shutting down through the game page is not the BEST idea instead I have a different idea. So first off make a model with nothing in it that no-one can take with the description “v1”

like this! Now get the id of the model!

Then write this in a server script!

while wait(60) – We put this in a while true do loop because :GetProductInfo gets the current info of the item.
local asset = game:GetService(“MarketPlaceService”):GetProductInfo(AssetIdHere)
if asset.Description == “v1” – Update this when you update the game
else
–Save Data and alert players
for i,plr in pairs(game.Players:GetPlayers()) do
plr:Kick(“The game has been updated please rejoin”)
end
end

Now what this will do is check if the products info is the current version if not then kick everyone!

So when you want to update the game and save the data simply change the description of your model and everyone will be kicked! K seeya! :slight_smile:

17 Likes

Neat idea, you might be better off checking it once when the server starts then comparing against that when the game .OnClose event is triggered to make sure that you can shut down yourself without worry of people joining old servers + no need to update the script itself.

5 Likes

OnClose always seems to not work for me for some reason not sure why…

Doesn’t fire in studio most of the times

even in the real game it does not seem to work…

OnClose is deprecated, use BindToClose instead.

One of the problems with OnClose is that it can only be set once (I think, or setting it a second time overrode the first function, something like that). BindToClose doesn’t have that problem.

2 Likes

however if you bindtoclose has a limit, if you can not save everything in that limit then… :grimacing:

2 Likes

I am not really sure about this method. I originally used descriptions to store fast flags for Ultimate Boxing, until the filter decided to destroy the description and take down product sales for about 10 minutes.

2 Likes

What kind of limit? The 30 seconds limit? OnClose has that too.

Also, for broadcasting messages to all servers, it’d just use GlobalDataStore:OnUpdate("Broadcast",handler) and use GlobalDataStore:SetAsync("Broadcast",message) in-game or in studio with “API Access” enabled.

im just saying the method im using does not have a limit.

We have something like this in an old game I helped making. Though we use the game’s place ID as the asset ID, and check the Updated field of the returned information from GetProductInfo. All went well until players were teleported back to the server which hadn’t yet closed after the 2-minute warning, and kept teleporting forth and back to the placeholder place for when updating happened :clap:

While it might be a simple way of dealing with getting servers closed down, I don’t think kicking your playerbase is a wise choice - some of them might not like the experience and leave your game in that case. :frowning:

2 Likes

true if only roblox servers closed faster…

I know. Long ago, when MarketplaceService just came out, I made a remote banlist (known as Synchronized Ban List, or SBL, which you’ll find plenty of in the Free Models) that made use of descriptions. I actually had two versions, as Roblox broke the first version after a few months:

May 02, 2013 ( 0.100.0.32485 → 0.101.0.33010 )
	Changed return type of MarketplaceService.GetProductInfo from string to Dictionary
December 20, 2012 ( 0.82.0.740 → 0.83.0.754 )
	Added Class MarketplaceService
	Added YieldFunction MarketplaceService.GetProductInfo

I love Anaminus’s API diff, such a handy thing

Only limit this had was that my banlists became much longer than the max length of a description, but that’s another story. (spoiler: sets)

also december 2012? It has been that long? wow

I have an alternative to this that uses Roblox’s existing shutdown system. When you shutdown all servers from the website, it teleports everyone into reserved servers for a few seconds, and then teleports them back into the main game. This means you will lose fewer players and reduces the likelihood of data loss.

28 Likes