So I have script that updates game settings when those values changes, but my saves doesn’t work
I’ve tried a lot of methods and nothing actually helped, there is no warning, no errors, just nothing, even prints not appearing
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local DataStoreService = game:GetService("DataStoreService")
local SettingsDS = DataStoreService:GetDataStore("Settings")
game.Players.PlayerAdded:Connect(function(player: Player)
task.wait(10)
local data
local success, err = pcall(function()
data = SettingsDS:GetAsync(player.UserId)
end)
if success and data then
print(data)
else
warn(err)
end
end)
game.Players.PlayerRemoving:Connect(function(player: Player, reason: Enum.PlayerExitReason)
local data = {
LowPerformance = player.PlayerGui.Settings.LowPerformance.Value,
MusicVolume = player.PlayerGui.Settings.MusicVolume.Value,
Walkspeed = player.PlayerGui.Settings.WalkSpeed.Value,
Trades = player.PlayerGui.Settings.Trades.Value
}
local success, err = pcall(function()
SettingsDS:SetAsync(player.UserId, data)
end)
if success then
print("successed")
end
end)
You actually just discovered the issue! Changing those values on the client (local-script) does not mean it is replicated to the server. The data is saved on the server and is the only way of saving your data.
Server automatically replicates to the client, but the client does not replicate to the server. This is intended and it is important it works like this.
So the fix is to make sure you changes those values on the server, using regular scripts! After that, the data should be correctly saved!