How USBX runs your code
Every USBX game is fully server authoritative.
Your game lives in one place
Client
- Sends what you press
input keys, clicks, touches
what to draw parts, players, screens
Server
Your scripts
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
Touches a part
part.touchedClicks a partpart.clickable = true, part.clickedPresses the interact keypart.prompt, part.interactedPresses a button on screenscreen.clickedTypes in a text boxscreen.submittedAnswers a popupui.popup(player, …)Sends a chat messageplayers.chattedPicks an NPC dialogue linenpc.dialogue_signalSits in a seatpart.occupiedOne tick on the server
What happens when a player steps on lava.
- 1Input arrives
The player walks forward.
- 2The player touches lava
They are now touching a part tagged "Lava".
- 3Your scripts run
touchedfires, and your script callsplayer:kill().
Talking between scripts
State
A value every script can read and change. Use it for scores, tokens and flags.
state.create_per_player →