Skip to main content

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:

  1. Get Services
  2. Require modules
  3. Add local functions
  4. 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

ServiceDescription
EnvironmentContains all the objects in your game world that will render
LightingContains all lighting effects of your world
HiddenContains 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

ServiceDescription
GameContains methods for events for frames
ScriptServiceWhere you can run local and server scripts to influence the game