I got help previously, but I am unaware of how to add more items. Please help
local datastore = game:GetService("DataStoreService"):GetDataStore("PointDS")
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Points = Instance.new("IntValue")
Points.Name = "Points"
Points.Parent = leaderstats
local Gold = Instance.new("IntValue") -- Gold is the extra value I'm trying to save.
Gold.Name = "Gold"
Gold.Parent = leaderstats
local key = "user-" .. player.userId
--I don't understand below here
local storeditems = datastore:GetAsync(key)
if storeditems then
Points.Value = storeditems[1]
else
local items = {Points.Value}
datastore:SetAsync(key, items)
end
end)
game.Players.PlayerRemoving:connect(function(player)
local items = {player.leaderstats.Points.Value}
local key = "user-" .. player.userId
datastore:SetAsync(key, items)
end)
If you for some reason need more information or code, lemme know what specific parts. I'm horrible with datastores but know the basics and some advanced works of Lua. So an in-depth explanation that covers individual parts would be nice

1 comment
Thank you so much!