What is wrong with this DataStorage script?
It saves "SaveValue", but it does not save "Regular", what am I doing wrong?
Here is my coding:
game.Players.PlayerAdded:connect(function(plr)
local uniquekey = "id-"..plr.userId
local leaderstats = Instance.new("IntValue")
leaderstats.Parent = plr
leaderstats.Name = "leaderstats"
local savevalue = Instance.new("IntValue")
savevalue.Parent = leaderstats
savevalue.Name = "Coins"
local Regular = Instance.new("IntValue")
Regular.Parent = plr
Regular.Name = "Regular"
--GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
savevalue.Value = GetSaved[1]
Regular.Value = GetSaved[2]
else
savevalue.Value = 1000000
Regular.Value = 0
local NumbersForSaving = {savevalue.Value, Regular.Value}
DSService:SetAsync(uniquekey,NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = "id-"..plr.userId
local SaveCoins = {plr.leaderstats.Coins.Value}
local SaveRegular = {plr.Regular.Value}
DSService:SetAsync(uniquekey,SaveCoins)
DSService:SetAsync(uniquekey,SaveRegular)
end)
Any help is greatly appreciated!
