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?
Script:
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)
