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.