Hi, so I have a strength leaderstat which should save when I leave the game. However, it does not do that. I have turned API Services on and have a bool value in server storage named SaveInStudio and the value is true. Can anyone help please?
local DataStore = game:GetService("DataStoreService") local ds = DataStore:GetDataStore("StrengthSaveSystem") game.Players.PlayerAdded:connect(function(player) local leader = Instance.new("Folder",player) leader.Name = "leaderstats" local Strength = Instance.new("IntValue",leader) Strength.Name = "Strength" Strength.Value = ds:GetAsync(player.UserId) or 0 ds:SetAsync(player.UserId, Strength.Value) Strength.Changed:connect(function() ds:SetAsync(player.UserId, Strength.Value) end) end) game.Players.PlayerRemoving:connect(function(player) ds:SetAsync(player.UserId, player.leaderstats.Strength.Value) end)
I have figured it out. It was because I was adding values from a local script when it should be from the server side. My mistake. The script works perfectly fine.