Skip to content
Untitled Sandbox - Developer Documentation
docs/how it works

How USBX runs your code

Every USBX game is fully server authoritative.

Your game lives in one place

Side by side: a ferry ticket

Here is a button that sails the player to a secret island for 15 tokens, written both ways.

other platforms2 scripts
SailButton.luau(client)
-- LocalScript, inside the button
local remote = game.ReplicatedStorage:WaitForChild("SailToIsland")

script.Parent.Activated:Connect(function()
  remote:FireServer()
end)
SailToIsland.luau(server)
-- Script, on the server
local remote = game.ReplicatedStorage.SailToIsland

remote.OnServerEvent:Connect(function(player)
  -- A cheater can fire this any time, so check everything.
  local tokens = player.leaderstats.Tokens
  if tokens.Value >= 15 and player.Character then
    tokens.Value -= 15
    player.Character:PivotTo(CFrame.new(0, 50, 500))
  end
end)
USBX1 script
Ferry.luau(server)
-- Script, on the server
local ferry = ui.mount(player, {
  kind = "panel", anchor = "bottom",
  children = {
    { kind = "button", id = "sail", text = "Sail: 15 tokens" },
  },
})

ferry.clicked:connect(function(who, id)
  if id == "sail" and tokens:get(who) >= 15 then
    tokens:increment(who, -15)
    who:teleport(math3d.vector3.new(0, 50, 500))
  end
end)

How players reach your scripts

One tick on the server

What happens when a player steps on lava.

  1. 1
    Input arrives

    The player walks forward.

  2. 2
    The player touches lava

    They are now touching a part tagged "Lava".

  3. 3
    Your scripts run

    touched fires, and your script calls player:kill().

Talking between scripts

Signal

Fire an event from one script and handle it in another.

signals.define →
State

A value every script can read and change. Use it for scores, tokens and flags.

state.create_per_player →
↑ ↓ moveEnter openEsc close