You could just create & publish a game, implement this:
game:BindToClose(function()
for Loop = 0, 100, 5 do
print(tostring(Loop).."%")
wait(0.5)
end
end)
That’ll print it attempting to slowly shut the game down
You could just create & publish a game, implement this:
game:BindToClose(function()
for Loop = 0, 100, 5 do
print(tostring(Loop).."%")
wait(0.5)
end
end)
That’ll print it attempting to slowly shut the game down
Thanks, but how can I see it in output if BindToClose only activates when I exit the game, thus removing any chance to see output in-game? Or do you mean do this in Test Mode? In other words, where is the output screen that I can see this happening?
Just shutdown your server from the website, forgot to mention that
(I mean that if you’re using it from the Player)
So if I shut down the server from the website I can see the output while still being in-game? What is the hotkey to do that again, is it F7?? Thanks for all the help.
W h a t
On the website where you join the game from, click “Servers”, then find your server with the 3 dot icons
You should see an option to shutdown the server
When I shut down the server the saving works, but when I leave it doesn’t save the inventory of the player. I’m not sure why that is. Does anybody know??
You should encase your data saving/calling as local functions, so you can easily connect them
I think when you shut down the server, since the player is still technically “in” the server, “local players = Players:GetPlayers()” works- but if you leave the game there are no players left, and that triggers the server to close so the length of Players:GetPlayers() is 0. Am I correct in thinking this?
That’s when the PlayerRemoving
Event should fire?
Just tested it, it doesn’t fire. Neither does BindToClose(), well i’m sure it runs code but it doesn’t find any players because I think leaving the game comes first, and then it realizes that the server needs to close so there are 0 players left in the server by the time that BindToClose() executes. I don’t think it was meant to save the data of the last player… I will see if there is a way to work around this.
Does your saving system have to run once and once only just before the server shuts down?
If not, I would recommend saving on an interval. That way you bypass your issue where BindToClose() is too late.
Forgive me if this has already been mentioned but,
You should be using BOTH the PlayerRemoving event and BindToClose() so when a player leaves (and thus fires the PlayerRemoving event) it saves the data, and BindToClose() comes in when the server is closed.
You could even make an interval that would save the username of all players that joined your game, and then when BindToClose() is ran, check if it could find a DataStore with that username. If not, send out e.g a discord webhook to notify you that it didn’t find a datastore with that username so you immediately know some data is lost.
how many other lies have the counsel told me?!?!?