DataModel

Visualizza obsoleti

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.

Non costruibile

Il Modello di dati (comunemente noto come game dopo la variabile globale utilizzata per accedervi) è la radice della gerarchia genitore-figlio di Roblox.I suoi figli diretti sono servizi, come Workspace e Lighting, che agiscono come componenti fondamentali di un GiocoRoblox.

Campioni di codice

Demonstrates using game, the root instance of DataModel, to get services such as Workspace and Lighting.

GetService()

local Workspace = game:GetService("Workspace")
local Lighting = game:GetService("Lighting")
-- Examples of modifying properties of these services
Workspace.Gravity = 20
Lighting.ClockTime = 4

Sommario

Proprietà

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Descrive l'ID dell'utente o del gruppo che possiede il Posto.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Descrive il Enum.CreatorType del Posto, se il luogo è di proprietà di un utente o di un Gruppo.

  • Sola Lettura
    Non Replicato
    Sicurezza Script Roblox
    Lettura Parallela
  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Descrive l'ID dell'esperienza a cui appartiene il luogo in esecuzione sul server.

  • Sola Lettura
    Non Replicato
    Lettura Parallela
    Obsoleto

    Non funzionale. Storicamente descritto il Enum.Genre del luogo come impostato sul sito Web di Roblox.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Un identificatore univoco per l'istanza del server di gioco in esempio.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Rappresenta come i giocatori nel server vengono gestiti dal matchmaking.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Descrive l'ID del luogo in esecuzione sul Server.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Descrive la versione del luogo su cui è in esecuzione il server.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Descrive l'ID del server privato del Server, se il server è un server privato o un reserved server .

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Descrive il UserId del Player che possiede il server privato se il server è Server privato.

  • Sola Lettura
    Non Replicato
    Lettura Parallela

    Un riferimento al servizio Workspace .

Metodi

  • BindToClose(function : function):()

    Lega una funzione da chiamare prima che il server si chiuda.

  • Sicurezza Plugin

    Restituisce una tabella che contiene informazioni di base sui lavori eseguiti dal Agendadi compiti.

  • GetObjects(url : ContentId):Instances
    Sicurezza Plugin
    Obsoleto

    Restituisce un array di Instances associato all'URL del contenuto fornito.

  • Restituisce vero se il client ha finito di caricare il gioco per la prima volta.

  • SetPlaceId(placeId : number):()
    Sicurezza Plugin

    Imposta il DataModel.PlaceId della istanza di gioco attuale al placeId dato.

  • SetUniverseId(universeId : number):()
    Sicurezza Plugin

    Imposta il DataModel.GameId della istanza di gioco attuale all'universoId dato.

Metodi provenienti da ServiceProvider
  • Scrivi Parallelo

    Restituisce il servizio specificato dalla classe data se è già stato creato, errori per un nome non valido.

  • Restituisce il servizio con il nome di classe richiesto, creandolo se non esiste.

Eventi

Eventi provenienti da ServiceProvider

Proprietà

CreatorId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà descrive l'ID dell'utente o del gruppo che possiede il Posto.Se la proprietà DataModel.CreatorType è 'Utente' allora CreatorId sarà il Player.UserId del proprietario del Posto.Se il DataModel.CreatorType è 'Gruppo' allora CreatorId sarà l'ID del gruppo che possiede il Posto.

Campioni di codice

This code sample will print an output when the user that owns the game, or a member of the group that owns the game joins the server.

To run this script, place it inside a Script in ServerScriptService

Detect when the place owner joins the game

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if game.CreatorType == Enum.CreatorType.User then
if player.UserId == game.CreatorId then
print("The place owner has joined the game!")
end
elseif game.CreatorType == Enum.CreatorType.Group then
if player:IsInGroup(game.CreatorId) then
print("A member of the group that owns the place has joined the game!")
end
end
end)

CreatorType

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà descrive il Enum.CreatorType del Posto, se il luogo è di proprietà di un utente o di un Gruppo.

Se il Enum.CreatorType è 'Utente' , allora la proprietà DataModel.CreatorId descriverà il UserId dell'account che possiede il Gioco.Se il CreatorType è 'Group' , allora descriverà l'ID del gruppo.

Campioni di codice

This code sample will print an output when the user that owns the game, or a member of the group that owns the game joins the server.

To run this script, place it inside a Script in ServerScriptService

Detect when the place owner joins the game

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if game.CreatorType == Enum.CreatorType.User then
if player.UserId == game.CreatorId then
print("The place owner has joined the game!")
end
elseif game.CreatorType == Enum.CreatorType.Group then
if player:IsInGroup(game.CreatorId) then
print("A member of the group that owns the place has joined the game!")
end
end
end)

Environment

Sola Lettura
Non Replicato
Sicurezza Script Roblox
Lettura Parallela

GameId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà descrive l'ID dell'esperienza a cui appartiene il luogo in esecuzione sul server.

Vedi anche

  • DataModel.PlaceId , che descrive l'ID del luogo in esecuzione sul Server
  • DataModel.JobId , che è un identificatore univoco per l'istanza di gioco del server in esecuzione
  • TeleportService , che è un servizio che può essere utilizzato per trasportare Players tra i giochi
Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà è rotta e non dovrebbe essere utilizzata.

Questa proprietà ha descritto storicamente il Enum.Genre del luogo come impostato sul sito Web di Roblox.

Questa Proprietà, insieme a DataModel.GearGenreSetting , non funziona più correttamente a causa dei generi esistenti sul sito Web Roblox che non sono riflessi nell'enumero Enum.Genre .Di Risultato, tentando di leggere questa proprietà potrebbe essere generato un errore.

JobId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà è un identificatore univoco per l'istanza del server di gioco in esempio.Si tratta di un identificatore universalmente univoco (UUID), il che significa che nessun server, passato o presente, avrà mai lo stesso ID.

Predefinito a una stringa vuota in Studio.

Vedi anche

MatchmakingType

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà rappresenta come i giocatori nel server vengono gestiti dal matchmaking.I giocatori con diversi MatchmakingTypes non possono essere in o teletrasportati sullo stesso Server.

Si noti che questa proprietà è valida solo sul server DataModel e sarà il valore Enum.MatchmakingType.Default per tutti i client, quindi si fa riferimento solo a questa proprietà all'interno di un lato server Script .

PlaceId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà descrive l'ID del luogo in esecuzione sul Server.

Se il luogo non è stato pubblicato su Roblox, questo ID corrisponderà al modello utilizzato.

Vedi anche

  • DataModel.GameId , che descrive l'ID dell'esperienza a cui appartiene l'attuale luogo
  • DataModel.JobId , che è un identificatore univoco per l'istanza di gioco del server in esecuzione
  • TeleportService , che è un servizio che può essere utilizzato per trasportare Players tra luoghi

PlaceVersion

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà descrive la versione del luogo su cui è in esecuzione il server.

Questo numero di versione corrisponde al numero di versione mostrato nella sezione Storia della versione delle impostazioni del Posto.Non è la versione attuale del client di Roblox.Questa proprietà è 0 per tutte le esperienze non pubblicate.

Quando viene creata un'istanza del server per un Posto, utilizza la versione attuale del Posto.Se il luogo viene aggiornato in seguito mentre questo server è in esecuzione, il server rimarrà alla sua versione attuale.

Questa proprietà può essere utilizzata per visualizzare un ScreenGui mostrando la versione attuale del gioco a Players per aiutare con il debugging.

Campioni di codice

This code sample will place a simple GUI in the StarterGui showing the place version the server is running at.

To use this sample, place it inside a Script in ServerScriptService.

Server version number GUI

local StarterGui = game:GetService("StarterGui")
local versionGui = Instance.new("ScreenGui")
local textLabel = Instance.new("TextLabel")
textLabel.Position = UDim2.new(1, -10, 1, 0)
textLabel.AnchorPoint = Vector2.new(1, 1)
textLabel.Size = UDim2.new(0, 150, 0, 40)
textLabel.BackgroundTransparency = 1
textLabel.TextColor3 = Color3.new(1, 1, 1)
textLabel.TextStrokeTransparency = 0
textLabel.TextXAlignment = Enum.TextXAlignment.Right
textLabel.TextScaled = true
local placeVersion = game.PlaceVersion
textLabel.Text = string.format("Server version: %s", placeVersion)
textLabel.Parent = versionGui
versionGui.Parent = StarterGui

PrivateServerId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà descrive l'ID del server privato del Server, se il server è un Serverprivato.

Se il server non è un Serverprivato, questa proprietà sarà una Stringavuota.

Server privati

I server privati si riferiscono al Seguendo:

PrivateServerId contro JobId

L'ID del server privato di un server è diverso dal DataModel.JobId. L'JobId è l'identificatore univoco dell'istanza attuale del server.

I server privati (server privati o riservati) possono avere più istanze di server associate a loro nel tempo.Questo perché, anche se solo un'istanza del server può essere eseguita contemporaneamente per un server privato, le nuove istanze del server possono aprirsi e chiudersi quando i giocatori si uniscono e lasciano il Gioco.Ad esempio, nessuna istanza del server è in esecuzione quando nessuno sta giocando nel server.L'ID del Server Privato sarà coerente in tutte queste istanze del server e il DataModel.JobId sarà unico per ciascuno di essi.

Vedi anche:

Campioni di codice

DataModel.PrivateServerId and DataModel.PrivateServerOwnerId can be used to detect if the current server instance is a standard server, a VIP server or a reserved server.

Detecting Private Servers

local function getServerType()
if game.PrivateServerId ~= "" then
if game.PrivateServerOwnerId ~= 0 then
return "VIPServer"
else
return "ReservedServer"
end
else
return "StandardServer"
end
end
print(getServerType())

PrivateServerOwnerId

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà descrive il UserId del Player che possiede il server privato se il server è Server privato.

Se il server è un server standard o riservato, questa proprietà verrà impostata su 0.

Questa proprietà potrebbe essere utilizzata per identificare se un Player è il proprietario del Serverprivato, ad esempio:


local Players = game:GetService("Players")
-- è questo un serverprivato?
if game.PrivateServerId ~= "" and game.PrivateServerOwnerId ~= 0 then
-- ascolta i nuovi giocatori aggiunti
Players.PlayerAdded:Connect(function(player)
-- controlla se il giocatore è il proprietario del server
if player.UserId == game.PrivateServerOwnerId then
print("The private server owner has joined the game")
end
end)
end

Vedi anche:

Campioni di codice

DataModel.PrivateServerId and DataModel.PrivateServerOwnerId can be used to detect if the current server instance is a standard server, a VIP server or a reserved server.

Detecting Private Servers

local function getServerType()
if game.PrivateServerId ~= "" then
if game.PrivateServerOwnerId ~= 0 then
return "VIPServer"
else
return "ReservedServer"
end
else
return "StandardServer"
end
end
print(getServerType())

Workspace

Sola Lettura
Non Replicato
Lettura Parallela

Questa proprietà è un riferimento al servizio Workspace . Indica sempre Workspace e non sarà mai nil .

Metodi

BindToClose

()

Lega una funzione da chiamare prima che il server si chiuda.Se la funzione legata accetta un parametro, passa Enum.CloseReason specificando il motivo per lo spegnimento del server.

Puoi legare più funzioni chiamando BindToClose() ripetutamente. Le funzioni legate vengono chiamate in parallelo e vengono eseguite allo stesso tempo.

Il server di esperienza attende 30 secondi per tutte le funzioni legate a fermarsi prima di chiudere.Dopo 30 secondi, il server si spegne anche se le funzioni sono ancora in esecuzione.

Per verificare che la sessione attuale non è in Roblox Studio, usa RunService:IsStudio() .Questo impedisce alle funzioni legate di completare la loro esecuzione nelle sessioni di test offline.

Quando usi DataStoreService, dovresti anche usare BindToClose per legare una funzione che salva tutti i dati non salvati a DataStores .Questo impedisce la perdita di dati se il server si spegne inaspettatamente.

Vedi anche:

Parametri

function: function

Una funzione chiamata prima che il server di esperienza si chiuda.Se la funzione legata accetta un parametro, passa Enum.CloseReason specificando il motivo per lo spegnimento del server.

Valore predefinito: ""

Restituzioni

()

Campioni di codice

The following code sample is an example of how DataModel:BindToClose() can be used to save player data in the event of a server shutdown. In this example, player data is stored in a dictionary named playerData with UserIds as keys.

Saving player data before shutting down

local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")
local playerDataStore = DataStoreService:GetDataStore("PlayerData")
local allPlayerSessionDataCache = {}
local function savePlayerDataAsync(userId, data)
return playerDataStore:UpdateAsync(userId, function(oldData)
return data
end)
end
local function onServerShutdown(closeReason)
if RunService:IsStudio() then
-- Avoid writing studio data to production and stalling test session closing
return
end
-- Reference for yielding and resuming later
local mainThread = coroutine.running()
-- Counts up for each new thread, down when the thread finishes. When 0 is reached,
-- the individual thread knows it's the last thread to finish and should resume the main thread
local numThreadsRunning = 0
-- Calling this function later starts on a new thread because of coroutine.wrap
local startSaveThread = coroutine.wrap(function(userId, sessionData)
-- Perform the save operation
local success, result = pcall(savePlayerDataAsync, userId, sessionData)
if not success then
-- Could implement a retry
warn(string.format("Failed to save %d's data: %s", userId, result))
end
-- Thread finished, decrement counter
numThreadsRunning -= 1
if numThreadsRunning == 0 then
-- This was the last thread to finish, resume main thread
coroutine.resume(mainThread)
end
end)
-- This assumes playerData gets cleared from the data table during a final save on PlayerRemoving,
-- so this is iterating over all the data of players still in the game that hasn't been saved
for userId, sessionData in pairs(allPlayerSessionDataCache) do
numThreadsRunning += 1
-- This loop finishes running and counting numThreadsRunning before any of
-- the save threads start because coroutine.wrap has built-in deferral on start
startSaveThread(userId, sessionData)
end
if numThreadsRunning > 0 then
-- Stall shutdown until save threads finish. Resumed by the last save thread when it finishes
coroutine.yield()
end
end
game:BindToClose(onServerShutdown)

The following example prints the close reason to the output. It prints Done after three seconds, and then allows Roblox to shut down the experience server.

The close reason matches one of the values in Enum.CloseReason.

Binding to and Handling Game Shutdown

game:BindToClose(function(closeReason)
print(`Closing with reason {closeReason}`)
task.wait(3)
print("Done")
end)

GetJobsInfo

Sicurezza Plugin

Restituisce una tabella che contiene informazioni di base sui lavori eseguiti dal Agendadi compiti.

Nel calcolo, un programmatore di attività è un sistema responsabile dell'esecuzione di compiti chiave negli intervalli appropriati.

Puoi anche trovare le statistiche del programmatore di compiti dal vivo nella finestra Programmatore di compiti in Roblox Studio.

La prima voce nella tabella restituita è un dizionario di riferimento che contiene le statistiche (o intestazioni) disponibili. È nel seguente formato:


{
["name"] = "name",
["averageDutyCycle"] = "averageDutyCycle",
["averageStepsPerSecond"] = "averageStepsPerSecond",
["averageStepTime"] = "averageStepTime",
["averageError"] = "averageError",
["isRunning"] = "isRunning",
}

Le successive entrate in tabella restituite sono dizionari che contengono le statistiche sopra riportate per i lavori eseguiti dal Agendadi compiti. Ad esempio:


{
["name"] = "Heartbeat",
["averageDutyCycle"] = 0,
["averageStepsPerSecond"] = 0,
["averageStepTime"] = 0,
["averageError"] = 0,
["isRunning"] = false,
}

Vedi anche:


Restituzioni

Una tabella che contiene informazioni sui lavori eseguiti dal Agendadi compiti, vedi sopra per il formato.

Campioni di codice

Here is an example of iterating over the job info.

Getting Jobs Info

local jobInfo = game:GetJobsInfo()
local jobTitles = jobInfo[1]
table.remove(jobInfo, 1)
local divider = string.rep("-", 120)
print(divider)
warn("JOB INFO:")
print(divider)
for _, job in pairs(jobInfo) do
for jobIndex, jobValue in pairs(job) do
local jobTitle = jobTitles[jobIndex]
warn(jobTitle, "=", jobValue)
end
print(divider)
end

GetObjects

Instances
Sicurezza Plugin

Questo metodo restituisce un array di Instances associato all'URL del contenuto fornito.Può essere utilizzato per inserire contenuti dalla libreria Roblox.Non è possibile inserire Sounds utilizzando questo metodo poiché non hanno un Instance associato a loro e hanno solo un URL del contenuto.

A differenza di InsertService:LoadAsset() , DataModel:GetObjects() non richiede che una risorsa sia "affidabile", intendendo che una risorsa non debba essere posseduta dall'utente registrato o creata da Roblox, per essere inserita.Tuttavia, se la risorsa non è di proprietà dell'utente registrato deve essere liberamente disponibile.

A causa del contesto di sicurezza di questa funzione, può essere utilizzata solo dai plugin o dalla barra dei comandi.Per un'alternativa che può essere utilizzata in Scripts e LocalScripts , vedi InsertService:LoadAsset() .

Parametri

url: ContentId

L'URL del contenuto fornito.

Valore predefinito: ""

Restituzioni

Instances

Un array di Instances associato all'URL del contenuto.

Campioni di codice

If you want to view a plugin's source code without installing it, you can use DataModel:GetObjects() to download the plugin. The code sample below includes a function that will take a plugin's website URL and insert the plugin into the currently selected Instance or the Workspace.

Due to GetObjects' security context, this function can only be used in the command line or in a plugin.

View a plugin's source code

local Selection = game:GetService("Selection")
local WEB_URL = "plugin URL here"
local function downloadPlugin(webURL)
-- get the content URL
local contentID = string.match(webURL, "%d+")
local contentURL = "rbxassetid://" .. contentID
-- download the objects
local objects = game:GetObjects(contentURL)
-- decide where to parent them
local selection = Selection:Get()
local parent = #selection == 1 and selection[1] or workspace
-- parent the objects
for _, object in pairs(objects) do
object.Parent = parent
end
end
downloadPlugin(WEB_URL)

The content ID of a Decal on the Roblox website is associated with a Decal Instance rather than the actual content ID of the texture.

The code below, will use DataModel:GetObjects() to insert Decal objects into place and read their Decal.Texture property to obtain the image content IDs.

To use this code sample, enter the web URLs of the decals you'd like to convert into the array named IMAGES (as strings). A dictionary with the converted textures will be outputted.

Batch convert decal IDs

local IMAGES = {
-- Insert Decal web URLs in an array here (as strings)
}
-- open the dictionary
local outputString = "textures = {"
-- utility function to add a new entry to the dictionary (as a string)
local function addEntryToDictionary(original, new)
outputString = outputString
.. "\n" -- new line
.. " " -- indent
.. '["'
.. original
.. '"]' -- key
.. ' = "'
.. new
.. '",' -- value
end
print("Starting conversion")
for _, webURL in pairs(IMAGES) do
-- get the content URL
local contentID = string.match(webURL, "%d+")
local contentURL = "rbxassetid://" .. contentID
local success, result = pcall(function()
local objects = game:GetObjects(contentURL)
return objects[1].Texture
end)
if success then
addEntryToDictionary(webURL, result)
else
addEntryToDictionary(webURL, "Error downloading decal")
end
task.wait()
end
print("Conversion complete")
-- close the dictionary
outputString = outputString .. "\n}"
-- print the dictionary
print(outputString)

IsLoaded

Quando tutte le iniziali Instances nel gioco hanno finito di replicarsi al client, questa funzione restituisce vero.

A meno che non siano parented a ReplicatedFirst , LocalScripts non eseguono fino a quando il gioco non è stato caricato.Il seguente snippet, eseguito da un LocalScript in ReplicatedFirst produce fino a quando il gioco non è stato caricato:


if not game:IsLoaded() then
game.Loaded:Wait()
end

Vedi anche:


Restituzioni

Se il client ha finito di caricare il gioco per la prima volta.

Campioni di codice

This sample demonstrates a custom loading screen with a basic TextLabel. The code should be placed in a LocalScript within ReplicatedFirst. To expand on this sample with loading screen animations, see the Custom Loading Screens article.

Custom Loading Screen

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- Create a basic loading screen
local screenGui = Instance.new("ScreenGui")
screenGui.IgnoreGuiInset = true
local textLabel = Instance.new("TextLabel")
textLabel.Size = UDim2.new(1, 0, 1, 0)
textLabel.BackgroundColor3 = Color3.fromRGB(0, 20, 40)
textLabel.Font = Enum.Font.GothamMedium
textLabel.TextColor3 = Color3.new(0.8, 0.8, 0.8)
textLabel.Text = "Loading"
textLabel.TextSize = 28
textLabel.Parent = screenGui
-- Parent entire screen GUI to player GUI
screenGui.Parent = playerGui
-- Remove the default loading screen
ReplicatedFirst:RemoveDefaultLoadingScreen()
--wait(3) -- Optionally force screen to appear for a minimum number of seconds
if not game:IsLoaded() then
game.Loaded:Wait()
end
screenGui:Destroy()

SetPlaceId

()
Sicurezza Plugin

Questa funzione imposta il DataModel.PlaceId della istanza di gioco alla posizione placeId data.

La configurazione di entrambi DataModel.PlaceId e DataModel.GameId è richiesta per accedere a DataStoreService quando il luogo non è pubblicato, ad esempio un file locale .rbxl.Vedi qui sotto per un esempio.Nota che ottenere l'accesso DataStoreService da Studio richiede la impostazione Abilita l'accesso Studio ai servizi API dal pannello Sicurezza in Impostazioni di gioco.


local DataStoreService = game:GetService("DataStoreService")
-- accedere al DataStore 'Data' impostando PlaceId a placeId e GameId a universeId.
game:SetPlaceId(placeId)
game:SetUniverseId(universeId)
local dataStore = DataStoreService:GetDataStore("Data")

Parametri

placeId: number

L'ID per impostare il DataModel.PlaceId a.

Valore predefinito: ""

Restituzioni

()

SetUniverseId

()
Sicurezza Plugin

Questa funzione imposta il DataModel.GameId della istanza di gioco attuale all'universoId dato.Questo è utile quando si testano file locali .rbxl che non sono stati pubblicati su Roblox.

Per accedere al DataStoreService in un Postonon pubblicato, sia DataModel:SetUniverseId() che DataModel:SetPlaceId() devono essere Impostare.

Parametri

universeId: number

L'ID per impostare il DataModel.GameId a.

Valore predefinito: ""

Restituzioni

()

Eventi

GraphicsQualityChangeRequest

Si accende quando l'utente richiede un aumento o una diminuzione della qualità grafica utilizzando le scorciatoie.

Questo evento si attiva nelle seguenti condizioni:

  • Se l'utente premere F10 , questo evento si attiva con un argomento betterQuality di true .
  • Se l'utente premere ShiftF10 , questo evento si attiva con un argomento betterQuality``false .

Questo evento non fornisce il livello attuale di qualità grafica o copre tutti gli aggiornamenti alla qualità grafica.Ad esempio, le modifiche apportate nel menu di evasione GUI principale non vengono registrate.

Puoi recuperare Enum.SavedQualitySetting di un utente usando UserGameSettings con il seguente snippet:


UserSettings():GetService("UserGameSettings").SavedQualityLevel

Se le impostazioni grafiche dell'utente sono impostate su automatico, allora il Enum.SavedQualitySetting sarà Automatic .Al momento non esiste alcun modo per i developer di ottenere affidabilmente il livello attuale della qualità grafica di una macchina dell'utente.

Parametri

betterQuality: boolean

Se l'utente ha richiesto un aumento ( vero ) o una diminuzione ( falso ) nella qualità grafica.


Campioni di codice

Handling User Changes in Graphics Quality

game.GraphicsQualityChangeRequest:Connect(function(betterQuality)
if betterQuality then
print("The user has requested an increase in graphics quality!")
else
print("The user has requested a decrease in graphics quality!")
end
end)

Loaded

Questo evento si attiva sul client quando tutto l'iniziale Instances nel gioco ha finito di replicare al client.

A meno che non siano parented a ReplicatedFirst , LocalScripts non eseguono fino a quando il gioco non è stato caricato.Il seguente snippet, eseguito da un LocalScript in ReplicatedFirst produce fino a quando il gioco non è stato caricato:


if not game:IsLoaded() then
game.Loaded:Wait()
end

Vedi anche: