How do I make a table for player stats, such as an inventory system. You use intvalue or numbervalue for a single stay but how do you make a table?
a table can be used to store multiple values of any type that exists:
yourTable = {
level = 10
coins = 500
}
in the minimum, use a server script
local PlayerData = {}
local Players = game:GetService(“Players”)
local function OnPlayerAdded(player)
PlayerData[player] = { Inventory = { } }
-- or retrieves from datastore
end
for _, player in Players:GetPlayers() do
OnPlayerAdded(player)
end
Players.PlayerAdded(OnPlayerAdded)