What are services?
Last updated
Was this helpful?
Last updated
Was this helpful?
Services are module scripts that serve a specific purpose within your experience. For example, you might have services dedicated to handling the user interface (UI), managing player points, or controlling game-specific logic.
To create a service, you’ll need to place a new ModuleScript
in one of the designated Knight service folders based on its purpose:
Server-side services: src/ServerStorage/Knight
Client-side services: src/StarterPlayer/StarterPlayerScripts/Knight
Shared services: src/ReplicatedStorage/Knight
Init()
: Called during the initialization phase of the service. This is optional and typically used for setting up any necessary data or connections before the service starts.
Start()
: Called when the service is ready to begin its main functionality. This is also optional and is typically used to start processes like event listeners, timers, etc.
Update(deltaTime)
: Called every frame. This function is optional and is used for tasks that need to be updated regularly, such as animations or game logic.
CanStart
, CanUpdate
, CanInit
:
These booleans determine whether the Start()
, Update()
, and Init()
functions will be called.
If you're using a third-party module and don't want Knight to call its default start function, set CanStart
to false
.
Folders named "Database" will have the first priority during initialization, followed by manual "Priority" set within the module. This is useful for ensuring that core game systems, such as data management, are loaded before other services.
The default priority levels are as follows:
Internal Services: 4
Objects: 3
Services: 2
You can adjust the startup priority by setting Knight.Priority
to a specific number in the script. Higher priority numbers indicate an earlier startup.
Optionally, if you have the instance named "Init" or "EnivornmentInit" or it has the collection tag "KNIGHT_IGNORE" it will be automatically ignored and not inited/imported into the framework.
We recommend using the Collection Tag only to mark Modules as in-active/disabled.
Each service in Knight follows a standard template structure:
Article & Art by vq9o