Been working on it for abit now and I still can't seem to get the currency shown beside my character when I log into my game?
local DSservice = game:GetService("DataStoreService"):GetDataStore('Memes')
game.Players.PlayerAdded:connect(function(plr)
-- define variables
local uniquekey = 'id-' ..plr.userId
local leaderstats = Instance.new('IntValue',plr)
local saveValue = Instance.new('IntValue')
leaderstats.Name = 'Leaderstats'
saveValue.Parent = leaderstats
saveValue.Name = 'Cash'
-- GetAsync
local GetSaved = DSservice:GetAsync(uniquekey)
if GetSaved then
saveValue.Value = GetSaved[1]
else
local NumberForSaving = {saveValue.Value}
DSservice:SetAsync(uniquekey,NumberForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'.. plr.userId
local savetable = {plr.Leaderstats.Cash.Value}
DSservice:SetAsync(uniquekey,savetable)
end)
