<!-- skill: Roblox Studio | version: 1.0.0 | description: Build Roblox games with Luau, DataStores and monetization | category: Games -->
## Instructions
- Write Luau with `--!strict`, Services via `game:GetService()`, `task.wait()` not `wait()`; separate server/client code.
- Enforce server/client boundary: server owns logic/data, client handles input/UI; bridge only via RemoteEvents/RemoteFunctions.
- Never trust the client: validate all RemoteEvent args on server (types, ranges, cooldowns, ownership checks).
- Persist with DataStores (ProfileService pattern): load on PlayerAdded, autosave every 120s, save on BindToClose.
- Implement leaderstats (`leaderstats` Folder + IntValue Coins/Kills) for XP/currency display; replicate sparingly.
- Rig avatars correctly: R15 vs R6, HumanoidRootPart anchoring, Welds/Motor6D for tools; test with multiple avatar scales.
- Toolbox safety: only insert from verified creators, audit scripts for `require(assetId)` / `getfenv` / HttpService exfil; sandbox first.
- Publish via Game Settings: enable Studio Access to API, configure permissions, version + update notes per release.
- Monetize with game passes, developer products, and Premium payouts; price passes 99-999 Robux, A/B test icons.
- Optimize: StreamingEnabled,LOD, part count budgets, use Attributes + CollectionService tags instead of deep hierarchies.
- Moderate: add TextChatService filtering, report hooks, anti-exploit sanity (speed/teleport checks server-side).
- Test with Play Solo + 3-player local server + Team Test; check output for DataStore `BudgetExceeded` warnings.
## Examples
- Example 1 — Coin pickup: server `Touched` awards 10 coins after debounce, validates Humanoid, updates leaderstats, fires client FX via RemoteEvent.
- Example 2 — DataStore save: `CoinsStore:SetAsync(userId, coins)` wrapped in pcall with retry + session lock to prevent dupes.
- Example 3 — Game pass door: client prompts purchase via MarketplaceService, server checks `UserOwnsGamePassAsync` before opening VIP area.
## Workflows
1. Setup: baseplate + Lighting (Future), Terrain, SpawnLocation, leaderstats script, DataStore module, RemoteEvents folder.
2. Build loop: prototype obby/tycoon/sim in 1 map, add 3 core systems (currency, save, shop), playtest with friends.
3. Harden: server validation, anti-exploit, Toolbox audit, performance pass (reduce unions, enable StreamingEnabled).
4. Publish: configure icon/thumbnail, age rating questionnaire, enable API access, publish to Roblox, test on mobile/console.
5. Monetize + iterate: add 2 game passes + 1 dev product, track retention (D1/D7), update weekly with patch notes.
## Templates
### Luau DataStore with retry (ServerScriptService)
```lua
--!strict
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local CoinsStore = DSS:GetDataStore("Coins_v1")
local function loadCoins(player: Player): number
  local ok, val = pcall(function()
    return CoinsStore:GetAsync("uid_"..player.UserId)
  end)
  if ok and typeof(val) == "number" then return val end
  return 0
end
Players.PlayerAdded:Connect(function(player)
  local ls = Instance.new("Folder"); ls.Name = "leaderstats"; ls.Parent = player
  local coins = Instance.new("IntValue"); coins.Name = "Coins"; coins.Value = loadCoins(player); coins.Parent = ls
end)
Players.PlayerRemoving:Connect(function(player)
  local ls = player:FindFirstChild("leaderstats")
  if ls then pcall(function() CoinsStore:SetAsync("uid_"..player.UserId, (ls :: any).Coins.Value) end) end
end)
```
### RemoteEvent coin grant (server validation)
```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local coinEvent = ReplicatedStorage:WaitForChild("AddCoins")
local cooldowns: {[number]: number} = {}
coinEvent.OnServerEvent:Connect(function(player, amount)
  if typeof(amount) ~= "number" then return end
  amount = math.clamp(math.floor(amount), 1, 50)
  local now = os.clock()
  if now - (cooldowns[player.UserId] or 0) < 1 then return end
  cooldowns[player.UserId] = now
  player.leaderstats.Coins.Value += amount
end)
```
### Leaderstats quick setup
```lua
-- put in ServerScriptService/Leaderstats.server.lua
game:GetService("Players").PlayerAdded:Connect(function(p)
  local f = Instance.new("Folder"); f.Name = "leaderstats"; f.Parent = p
  for _, n in {"Coins","Kills"} do local v = Instance.new("IntValue"); v.Name = n; v.Value = 0; v.Parent = f end
end)
```
## Tools
- Roblox Studio, Luau LSP + StyLua, Rojo + Wally for packages, ProfileService/DataStore2 modules.
- Toolbox (vetted), Krnl-free playtest clients, Game Analytics + Developer Stats dashboard.
- MarketplaceService for passes, Localization Tools for multi-language, Avatar Setup for rigs.
## Advanced
- Use MemoryStoreService for session locks/queues; shard DataStores by key prefix to avoid throttling (60s budgets).
- Implement server-authoritative movement checks: track HumanoidRootPart CFrame deltas, kick on >80 studs/sec anomalies.
- Run A/B icon tests, funnel analytics (tutorial completion), live-ops calendar with seasonal passes.
## Documentation
- https://create.roblox.com/docs
- https://create.roblox.com/docs/scripting/luau
- https://create.roblox.com/docs/cloud-services/datastores
- https://create.roblox.com/docs/production/monetization
