I'm creating a script that saves the game's settings, such as music. I have a LocalScript with a table that when I press the button to remove the music, it becomes false.
local Settings = {
Music = true
}
When the player leaves the game it should to fire an event (that's always in the LocalScript).
game.Players.PlayerRemoving:Connect(function(player)
local Table = {Settings.Music}
SaveSettings:FireServer(Table)
end)
Then in a server script I have this:
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("SettingsStats")
game.ReplicatedStorage.EventFunction.RemoteEvent.SaveSettings.OnServerEvent:Connect(function(player, Settings)
ds:SetAsync(player.UserId, Settings)
print("Success!")
end)
The problem is that it does not fire the server when the player leaves. Where am I wrong? I'll wait for an answer.

4 comments
i wouldn't do that to be honest, you could add like manual saving or save the settings whenever they're editted.
hunter, that's incorrect. you shouldn't have autosaving. if people leave within the cooldown interval, you will get throttled. instead you should use saving on leaving.
I believe its because you're giving it the table local Table = {Settings.Music} . Thats actually just creating a key with a nil value i think. Instead, give it the table directly, or say Table = {["Music"] = Settings.Music}
I'