game
Root object of the API. Provides service lookup, server lifecycle events and broadcast on-screen text.
Methods
GetService
game:GetService(name: string): ServiceReturns the named service. Raises an error if the service is not available in the current context.
| Service | Server | Client |
|---|---|---|
| Players | ✓ | ✓ |
| World | ✓ | ✓ |
| Teams | ✓ | ✓ |
| Tools | ✓ | ✓ |
| Remote | ✓ | ✓ |
| State | ✓ | ✓ |
| DataStore | ✓ | |
| Storage | ✓ | |
| UI | ✓ | |
| Input | ✓ | |
| Effects | ✓ | |
| Build | ✓ |
local Players = game:GetService("Players")Announce
game:Announce(text: string, seconds: number?)Displays text centered over a dimmed overlay on every client for seconds (1 to 15, default 6). Server only.
Rate limited to one announcement per 2 seconds. Calls inside that window are dropped. Use Message for frequently updated text such as countdowns.
game:Announce("Round starting on Red Map!", 3)Message
game:Message(text: string, seconds: number?)Displays text in a bar along the top edge of every client's screen. Server only.
- If
secondsis omitted, the message persists until replaced. - An empty string clears the message.
- The current message is sent to players who join while it is shown.
for left = 10, 1, -1 do
game:Message("Intermission: " .. left)
task.wait(1)
end
game:Message("")Events
Started
game.Started()Fires once, after every server script has started.
Shutdown
game.Shutdown()Fires before the server shuts down.
game.Shutdown:Connect(function()
print("Server closing")
end)