Services
Polytoria has services that lets you access the engine built-in features, such as players, the camera, backpack, and the environment.
To define a service in Polytoria you use game["ServiceName"]
Services are generally the first step when writing your code:
- Get Services
- Require modules
- Add local functions
- Add events
For example if you want to add a tool to the player's backpack when they join the game:
local Players = game["Players"] -- We get the players service
local function giveTool(player) -- Our local function
local backpack = player:FindChild("Backpack")
if backpack then
-- We clone a tool and set it's parent to the backpack
end
end
Players.PlayerAdded:Connect(giveTool) -- Connect to the event
To retrieve a service, you use the game global, which references the root data model of your game.
Container Services
Some services can contain and influence other objects, such as the Backpack service we used above, which is a link to the player's backpack
| Service | Description |
|---|---|
| Environment | Contains all the objects in your game world that will render |
| Lighting | Contains all lighting effects of your world |
| Hidden | Contains content and logic that can be shared with both the client and the server |
To get more information about the data model you can use the methods:
game:GetChildren()
Scripting Services
These services provide functionality to the Polytoria engine with scripts. These are the most common ones
| Service | Description |
|---|---|
| Game | Contains methods for events for frames |
| ScriptService | Where you can run local and server scripts to influence the game |