Skip to main content

Getting started

Player data with the whole lifecycle handled takes one call. Each player's data loads when they join, autosaves, and is saved and released when they leave or the server shuts down.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Geode = require(ReplicatedStorage.Packages.Geode)

local PlayerData = Geode.players({
name = "PlayerData",
template = { coins = 0, xp = 0, level = 1, inventory = {} },
replicate = { coins = "owner", level = "public" },
})

PlayerData:onLoaded(function(player, profile)
profile:increment("coins", 100)
end)

replicate sends coins to its owner and level to everyone. Every other path stays on the server. On the client, those paths arrive as atoms:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Geode = require(ReplicatedStorage.Packages.Geode)

local client = Geode.Client.start()
client:atom("coins"):subscribe(function(coins)
print("coins", coins)
end)

Where to go next​