Can anyone tell me why this DataStore is not working..
local DataStoreService = game:GetService("DataStoreService"):GetDataStore("Hello")
game.Players.PlayerAdded:Connect(function(plr)
local uniquekey = "id-"..plr.userId
local leaderstats = Instance.new("IntValue",plr)
local savevalue = Instance.new("IntValue")
local savevalue2 = Instance.new("IntValue")
local savevalue3 = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
savevalue.Parent = leaderstats
savevalue.Name = "Money"
savevalue2.Parent = leaderstats
savevalue2.Name = "Subscribers"
savevalue3.Parent = leaderstats
savevalue3.Name = "Followers"
local GetSaved = DataStoreService:GetAsync(uniquekey)
if GetSaved then
savevalue.Value = GetSaved[1]
savevalue2.Value = GetSaved[2]
savevalue3.Value = GetSaved[3]
else
local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value}
DataStoreService:SetAsync(uniquekey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = "id-"..plr.userId
local Savetable = {plr.leaderstats.Cash.Value, plr.leaderstats.Subscribers.Value, plr.leaderstats.Followers.Value}
DataStoreService:SetAsync(uniquekey, Savetable)
end)

9 comments
@MaximumOverdriven That dosen't work.
It dosen't save the data
yes it does
When the player leaves itsaves the data
let me explain to you, getasync loads the data and if there is no data we getan empty array which represents {}, next we load the values and if there is no value, we make 0 our default; with the or . You shouldn't be setting the async in the playeradded event
I KNOW WHAT THE PROBLEM IS
Bro, I went into developer console gave me subs etc, I see it on the leaderboard and when I rejoin its gone..
in the player removing event, you did plr.leaderstats.Cash.Value; when it should be plr.leaderstats.Money.Value
accept answer if im right :)