Man, the localscripts delete before the Players.PlayerRemoving event is called.
how do you know it doesn’t work in-game?
Because it doesn’t save my data at all. I also tested with some of my friends and the server log doesn’t print that it receives the remote event from the client.
-- Fires to the client so that it fires back with the data to save, but server doesnt receive the event?
local function onPlayerRemoving(player: Player)
remoteEvents.SaveKeybinds:FireClient(player)
remoteEvents.SaveSettings:FireClient(player)
end
I’d be willing to hand out a complete game file for anyone willing to help me, I have lots of people waiting for an update and so far I’ve gotten nowhere with this.
Stop complicating that much man. Why not use remoteevents to send input to server which it stores and saves it when player leaves?
i dont think you can fire to a client that isn’t in game, let alone have it fire back
i found this that might be relevant: How to send data from client to server when player is removed - #9 by minimic2002
This seems like a good solution. If it doesnt work then you can share a game file (not publicly of course, but to someone here privately)
Oh, I didn’t see their full code. Using RemoteFunctions on the server for client events is a little risky because the client can yield the server indefinitely, which would allow clients to prevent the other player’s data from saving if the server relies on BindToClose.
Granted they could write some code to run them async and stop yielding when all the functions finish to not allow one client to hold up saving while also still yielding for the saving to finish. Though that code requires making some signals and shared variables and stuff.
thats why you always have a time limit for client-defined yields
What do you mean? Could you explain this more
he means sending the data to the server while the player is still in game, then saving it when they leave (or just saving it during their gameplay)
i think its a good solution because it can mitigate data loss
Oh, are you saying that I should recode my data system so that it whenever the player wants to change a keybind, it will send their input to the server which stores it in a table? then get the data for that player when leaving and save it etc?
Actually, that doesn’t sound like a bad idea
yes
it wouldnt require that much of a recode either
hmmm, I would have to rewrite all the client stuff that uses the shared keybinds module… I might get confused at some parts
Could I contact you privately for any issues I have with this rewrite?
I would just start over rather than recoding
Yeah, that’s what I’m going to do
Thank you everyone for the amount of help you gave me, I am decent at scripting but I am VERY unfamiliar with datastores as I learned about datasaving only a few weeks ago.
I will be rewriting my data saving system now
it appears I have been summoned, my advice would be to fire the server through like a confirmation on settings, rather than trying to save data last second, you never know how much usage is going on with datastores so its better to at least send the information to the server to give it plenty of time to save it.
this way the player will be able to update their settings and the server can recieve the changes and save it when it can, usually there isnt delays but dont take anything for granted when it comes down to datastores or anything with a usage limit.
Edit: Reading through it looks like you reached this conclusion, but another opinon that your on the right track helps I guess, happy scripting
Well, the way I did it is the server has a module with data that only gets saved when the player leaves or the game closes. The client can fire events to change certain data of that server table.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.