So I've been expanding on Datastores and was wondering if this is what a Datastore would look like if there was a LeaderStat that was called "Pizza"?
local store = game:GetService("DataStoreService"):GetOrderedDataStore("Star Shards")
game.Players.PlayerAdded:connect(function(player)
player:WaitForDataReady()
local pKey = "plr_"..player.Name
local ls = Instance.new("IntValue", player)
ls.Name = "leaderstats"
local Pizza = Instance.new("IntValue", ls), Instance.new("IntValue", ls)
Pizza.Name = "Pizza"
local mode = Instance.new("BoolValue", player)
mode.Name, mode.Value = "playing", true
local wins = Instance.new("IntValue", ls)
Pizza.Name = "Pizza"
Pizza.Value = 0
Pizza.Value = 0
if store:GetAsync(pKey) ~= nil then
Pizza.Value = store:GetAsync(pKey)
else
Pizza.Value = 0
end
Pizza.Changed:connect(function(value)
store:SetAsync(pKey, value)
end)
end)
