I don’t usually like posting my scripts on here asking what is wrong, but I wrote up a datastore script and I am receiving no errors, however it isn’t saving my leaderboard stats when in-game in studio.
Here is the script:
local DSService = game:GetService('DataStoreService'):GetDataStore('Stage')
local Bool = script:WaitForChild("Stage")
game.Players.PlayerAdded:Connect(function(Player)
local leaderstats = Instance.new("IntValue", Player)
leaderstats.Name = "leaderstats"
local Cloned = Bool:Clone()
Cloned.Parent = leaderstats
local uniquekey = "StageLevel"..Player.UserId
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
Player:WaitForChild("leaderstats"):WaitForChild("Stage").Value = (GetSaved[1])
else
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
local uniquekey = "StageLevel"..Player.UserId
local Savetable = {Player:WaitForChild("leaderstats"):WaitForChild("Stage").Value}
DSService:SetAsync(uniquekey, Savetable)
end)