DataModel

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음

데이터 모델(일반적으로 액세스하는 전역 변수 이후에 알려진 데이터 모델)은 Roblox의 부모-자식 계층의 루트입니다.직접 자식은 Roblox 게임의 기본 구성 요소로 작용하는 서비스, 예를 들어 WorkspaceLighting ,입니다.

코드 샘플

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

요약

속성

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    플레이스소유하는 사용자 또는 그룹의 ID를 설명합니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    플레이스Enum.CreatorType를 설명하며, 장소가 사용자 또는 그룹에 소유되었는지 여부를 설명합니다.

  • 읽기 전용
    복제되지 않음
    Roblox 스크립트 보안
    병렬 읽기
  • 읽기 전용
    복제되지 않음
    병렬 읽기

    서버에서 실행 중인 장소가 속한 경험의 ID를 설명합니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기
    사용되지 않음

    기능적이지 않음. 역사적으로 장소의 Enum.Genre를 Roblox 웹사이트에 설정된 것으로 묘사했습니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    실행 중인 게임 서버 인스턴스의 고유 식별자.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    서버의 플레이어가 매치메이킹으로 처리되는 방식을 나타냅니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    서버에서 실행 중인 장소의 ID를 설명합니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    서버가 실행 중인 장소의 버전을 설명합니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    서버가 개인 서버인 경우 서버의 개인 서버 ID 또는 reserved server 를 설명합니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    서버가 비공개인 경우 비공개 서버를 소유하는 의 설명입니다.

  • 읽기 전용
    복제되지 않음
    병렬 읽기

    Workspace 서비스에 대한 참조.

메서드

  • BindToClose(function : function):()

    서버가 종료되기 전에 호출할 함수를 바인딩합니다.

  • 플러그인 보안

    태스크 스케줄러에서 수행한 작업에 대한 기본 정보가 포함된 테이블을 반환합니다.

  • GetObjects(url : ContentId):Instances
    플러그인 보안
    사용되지 않음

    지정된 콘텐츠 URL과 연결된 배열 Instances를 반환합니다.

  • 클라이언트가 처음으로 게임을 로드하는 것을 완료했는지 여부에 따라 반환합니다. true를 반환합니다.

  • SetPlaceId(placeId : number):()
    플러그인 보안

    현재 게임 인스턴스의 DataModel.PlaceId를 지정된 placeId로 설정합니다.

  • SetUniverseId(universeId : number):()
    플러그인 보안

    현재 게임 인스턴스의 DataModel.GameId를 지정된 universId로 설정합니다.

메서드ServiceProvider에서 상속되었습니다

메서드

  • 병렬 쓰기

    지정된 className에 의해 이미 생성된 경우 지정된 서비스를 반환하고 유효하지 않은 이름에 대한 오류를 발생시킵니다.

  • 요청한 클래스 이름으로 서비스를 반환하고, 존재하지 않으면 생성합니다.

이벤트

이벤트ServiceProvider에서 상속되었습니다

이벤트

속성

CreatorId

읽기 전용
복제되지 않음
병렬 읽기

코드 샘플

장소 소유자가 게임에 참여할 때 감지

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

읽기 전용
복제되지 않음
병렬 읽기

코드 샘플

장소 소유자가 게임에 참여할 때 감지

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

읽기 전용
복제되지 않음
Roblox 스크립트 보안
병렬 읽기

GameId

읽기 전용
복제되지 않음
병렬 읽기
읽기 전용
복제되지 않음
병렬 읽기

JobId

읽기 전용
복제되지 않음
병렬 읽기

MatchmakingType

읽기 전용
복제되지 않음
병렬 읽기

PlaceId

읽기 전용
복제되지 않음
병렬 읽기

PlaceVersion

읽기 전용
복제되지 않음
병렬 읽기

코드 샘플

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

읽기 전용
복제되지 않음
병렬 읽기

코드 샘플

개인 서버 감지

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

읽기 전용
복제되지 않음
병렬 읽기

코드 샘플

개인 서버 감지

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

읽기 전용
복제되지 않음
병렬 읽기

메서드

BindToClose

()

매개 변수

function: function
기본값: ""

반환

()

코드 샘플

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)
게임 종료 바인딩 및 처리

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

GetJobsInfo

플러그인 보안

반환

코드 샘플

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
플러그인 보안

매개 변수

url: ContentId
기본값: ""

반환

Instances

코드 샘플

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)
일괄 변환 데칼 ID 변환

local IMAGES = {
-- 여기에 배열에 데칼 웹 URL을 삽입(문자열로)
}
-- 사전 열기
local outputString = "textures = {"
-- 사전에 새 항목을 추가하는 유틸리티 함수(문자열로)
local function addEntryToDictionary(original, new)
outputString = outputString
.. "\n" -- 새 줄
.. " " -- 인디언트
.. '["'
.. original
.. '"]' -- 키
.. ' = "'
.. new
.. '",' -- 값
end
print("Starting conversion")
for _, webURL in pairs(IMAGES) do
-- 콘텐츠 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")
-- 사전 닫기
outputString = outputString .. "\n}"
-- 사전 출력
print(outputString)

IsLoaded


반환

코드 샘플

사용자 지정 로딩 화면

local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- 기본 로딩 화면 생성
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
-- 플레이어 GUI에 전체 화면 GUI 부모 지정
screenGui.Parent = playerGui
-- 기본 로딩 화면 제거
ReplicatedFirst:RemoveDefaultLoadingScreen()
--wait(3) -- 선택적으로 최소 시간 동안 화면 표시 강제
if not game:IsLoaded() then
game.Loaded:Wait()
end
screenGui:Destroy()

SetPlaceId

()
플러그인 보안

매개 변수

placeId: number
기본값: ""

반환

()

SetUniverseId

()
플러그인 보안

매개 변수

universeId: number
기본값: ""

반환

()

이벤트

GraphicsQualityChangeRequest

매개 변수

betterQuality: boolean

코드 샘플

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