Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem with the Fire Server on Player Removing. Where I am wrong?

Asked by 4 years ago
Edited 4 years ago

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.

0
i wouldn't do that to be honest, you could add like manual saving or save the settings whenever they're editted. Is_Hunter 152 — 4y
0
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. Fifkee 2017 — 4y
0
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} Psudar 882 — 4y
0
I' Patriq_Kane 8 — 4y

Answer this question