Class · inherits ServiceProvider
DataModel
About DataModel
The Data Model (commonly known as game
after the global variable used to access it) is the root of Roblox's
parent-child hierarchy. Its direct children are services, such as
Workspace and Lighting, that act as the fundamental components
of a Roblox game.
Properties 11
CreatorId
: int64ReadOnlyNotReplicatedDescribes the ID of the user or group that owns the place.This property describes the ID of the user or group that owns the place. If the
DataModel.CreatorTypeproperty isUserthenCreatorIdwill be thePlayer.UserIdof the place's owner. If theDataModel.CreatorTypeisGroupthenCreatorIdwill be the ID of the group that owns the place.CreatorType
: CreatorTypeReadOnlyNotReplicatedDescribes theCreatorTypeof the place, whether the place is owned by a user or a group.This property describes the
CreatorTypeof the place, whether the place is owned by a user or a group. IfUser, then theDataModel.CreatorIdproperty will describe theUserIdof the account that owns the game. IfGroup, then it will describe the group ID.GameId
: int64ReadOnlyNotReplicatedDescribes the ID of the experience that the place running on the server belongs to.This property describes the ID of the experience that the place running on the server belongs to.
See Also
DataModel.PlaceId, which describes the ID of the place running on the serverDataModel.JobId, which is a unique identifier for the server game instance runningTeleportService, which is a service that can be used to transportPlayersbetween games
JobId
: stringReadOnlyNotReplicatedA unique identifier for the running game server instance.This property is a unique identifier for the running game server instance. It is a universally unique identifier (UUID), meaning that no two servers, past or present, will ever have the same ID.
Defaults to an empty string in Studio.
See Also
TeleportService.GetPlayerPlaceInstanceAsyncwhich can be used to retrieve theDataModel.JobIdof a user's current server.TeleportService.TeleportToPlaceInstancewhich can be used to teleport aPlayerto a specific server.DataModel.PrivateServerIddescribes the ID of the private server the game server instance belongs to.HttpService.GenerateGUID, a function that can be used to generate your own UUIDs.
MatchmakingType
: MatchmakingTypeReadOnlyNotReplicatedRepresents how players in the server are handled by matchmaking.This property represents how players in the server are handled by matchmaking. Players with different
MatchmakingTypescannot be in or teleport to the same server.Note that this property is only valid on the server
DataModeland it will be theMatchmakingType.Defaultvalue for all clients, so only reference this property inside of a server‑sideScript.PlaceId
: int64ReadOnlyNotReplicatedDescribes the ID of the place running on the server.This property describes the ID of the place running on the server.
If the place has not been published to Roblox, this ID will correspond with the template being used.
See Also
DataModel.GameId, which describes the ID of the experience that the current place belongs toDataModel.JobId, which is a unique identifier for the server game instance runningTeleportService, which is a service that can be used to transportPlayersbetween places
PlaceVersion
: intReadOnlyNotReplicatedDescribes the version of the place the server is running on.This property describes the version of the place the server is running on.
This version number corresponds with the version number shown under the Version History section of the place's settings. It is not the current version of the Roblox client. This property is 0 for all unpublished experiences.
When a server instance is created for a place, it uses the place's current version. If the place is later updated while this server is running, the server will remain at its current version.
This property can be used to display a
ScreenGuishowing the current version of the game toPlayersto assist with debugging.PrivateServerId
: stringReadOnlyNotReplicatedDescribes the private server ID of the server, if the server is a private server or areserved server.This property describes the private server ID of the server, if the server is a private server.
If the server is not a private server, then this property will be an empty string.
Private servers
Private servers refer to the following:
- Private servers that users can purchase from the games page
- Reserved servers, private servers created by the developer using
TeleportService.ReserveServerAsync
PrivateServerId vs JobId
The PrivateServerId of a server is different from the
DataModel.JobId. TheJobIdis the unique identifier of the current server instance.Private servers (private or reserved servers) can have multiple server instances associated with them over time. This is because, although only one server instance can be running at once for a private server, new server instances can open and close as players join and leave the game. For example, no server instance is running when nobody is playing in the server. The PrivateServerId will be consistent across all of these server instances, and the
DataModel.JobIdwill be unique for each one.See also:
DataModel.PrivateServerOwnerId, a property describing the owner of a private serverTeleportService.ReserveServerAsync, a function which creates a reserved server
PrivateServerOwnerId
: int64ReadOnlyNotReplicatedDescribes theUserIdof thePlayerthat owns the private server if the server is private.This property describes the
UserIdof thePlayerthat owns the private server if the server is private.If the server is a standard or reserved server then this property will be set to
0.This property could be used to identify if a
Playeris the owner of the private server, for example:local Players = game:GetService("Players") -- is this a private server? if game.PrivateServerId ~= "" and game.PrivateServerOwnerId ~= 0 then -- listen for new players being added Players.PlayerAdded:Connect(function(player) -- check if the player is the server owner if player.UserId == game.PrivateServerOwnerId then print("The private server owner has joined the game") end end) endSee also:
DataModel.PrivateServerId, a property describing the unique ID of private andreserved servers
RunService
: RunServiceReadOnlyNotReplicatedA reference to theRunServiceservice.A reference to the
RunServiceservice. Always points toRunServiceand is nevernil. You can also retrieve it withGetService(), for examplegame:GetService("RunService").
Methods 5
BindToClose
(function: Function) → ()Binds a function to be called before the server shuts down.Binds a function to be called before the server shuts down. If the bound function accepts a parameter, it passes
CloseReasonspecifying the reason for the server shutdown.You can bind multiple functions by calling
BindToClose()repeatedly. Bound functions are called in parallel and run at the same time.The experience server waits 30 seconds for all bound functions to stop running before it shuts down. After 30 seconds, the server shuts down even if functions are still running. Teleports are disabled during moderation shutdowns.
To verify that the current session is not in Roblox Studio, use
RunService.IsStudio. This prevents bound functions from completing their run in offline testing sessions.When you use
DataStoreService, you should also useBindToCloseto bind a function saving all unsaved data toDataStores. This prevents data loss if the server shuts down unexpectedly.See also:
CloseReasonfor reasons for the experience server shutdown.PluginGui.BindToClose, which binds a function to aPluginGuiclose button.
GetJobsInfo
() → ArrayPluginReturns a table containing basic information about the jobs performed by the task scheduler.Returns a table containing basic information about the jobs performed by the task scheduler.
In computing, a task scheduler is a system responsible for executing key tasks at the appropriate intervals.
You can also find live task scheduler statistics in the Task Scheduler window in Roblox Studio.
The first entry in the table returned is a reference dictionary containing the statistics (or headings) available. It is in the following format:
{ ["name"] = "name", ["averageDutyCycle"] = "averageDutyCycle", ["averageStepsPerSecond"] = "averageStepsPerSecond", ["averageStepTime"] = "averageStepTime", ["averageError"] = "averageError", ["isRunning"] = "isRunning", }The subsequent entries in the table returned are dictionaries containing the above statistics for jobs performed by the task scheduler. For example:
{ ["name"] = "Heartbeat", ["averageDutyCycle"] = 0, ["averageStepsPerSecond"] = 0, ["averageStepTime"] = 0, ["averageError"] = 0, ["isRunning"] = false, }See also:
IsLoaded
() → booleanReturns true if the client has finished loading the game for the first time.When all initial
Instancesin the game have finished replicating to the client, this function returns true.Unless they are parented to
ReplicatedFirst,LocalScriptsdo not run until the game has loaded. The following snippet, run from aLocalScriptinReplicatedFirstyields until the game has loaded:if not game:IsLoaded() then game.Loaded:Wait() endSee also:
- Replication order for a more detailed summary of the loading process.
DataModel.Loaded, an event that fires when the game has loadedInstance.WaitForChild, a function which can be used to wait for an individualInstanceto replicate without having to wait for the whole game to finish loading.
SetPlaceId
(placeId: int64) → ()PluginSets theDataModel.PlaceIdof the current game instance.This function sets the
DataModel.PlaceIdof the game instance to the givenplaceId.SetUniverseId
(universeId: int64) → ()PluginSets theDataModel.GameIdof the current game instance to the givenuniverseId.This function sets the
DataModel.GameIdof the current game instance to the givenuniverseId. This is useful when testing local .rbxl files that have not been published to Roblox.To access the
DataStoreServicein an unpublished place, bothDataModel.SetUniverseIdandDataModel.SetPlaceIdmust be set.
Events 3
GraphicsQualityChangeRequest
DataModel.GraphicsQualityChangeRequest:Connect(function(betterQuality))Fires when the user prompts and increase or decrease in graphics quality using the hotkeys.Fires when the user prompts an increase or decrease in graphics quality using the hotkeys.
This event fires under the following conditions:
- If the user presses F10, this event fires with a
betterQualityargument oftrue. - If the user presses ShiftF10, this event fires
with a
betterQualityargument offalse.
This event does not provide the current graphics quality level or cover all updates to the graphics quality. For example, changes made in the core GUI escape menu are not registered.
You can retrieve a user's
SavedQualitySettingusingUserGameSettingswith the following snippet:UserSettings():GetService("UserGameSettings").SavedQualityLevelIf the user's graphics settings are set to automatic then the
SavedQualitySettingwill beAutomatic. There is currently no way for developers to reliably get the current graphics quality level of a user's machine.- If the user presses F10, this event fires with a
Loaded
DataModel.Loaded:Connect(function())Fires on the client when the game finishes loading for the first time.This event fires on the client when all initial
Instancesin the game have finished replicating to the client.Unless they are parented to
ReplicatedFirst,LocalScriptsdo not run until the game has loaded. The following snippet, run from aLocalScriptinReplicatedFirstyields until the game has loaded:if not game:IsLoaded() then game.Loaded:Wait() endSee also:
- Replication order for a more detailed summary of the loading process.
DataModel.Loaded, an event that fires when the game has loadedInstance.WaitForChild, a function which can be used to wait for an individualInstanceto replicate without having to wait for the whole game to finish loading.
ServerRestartScheduled
DataModel.ServerRestartScheduled:Connect(function(restartTime, source, attributes))Fires on the server when the server has been scheduled to restart. Provides the scheduled restart time, source, and custom attributes.Fires when the server has been scheduled to restart, for example when you restart servers from the Creator Hub or Open Cloud to release an experience update, or when Roblox needs to restart servers for infrastructure maintenance.
You can use this event to inform players on the server of the impending restart. You could then let them save their progress or teleport them to updated servers at the most convenient time for your game.
DataModel also has every member of ServiceProvider. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.