Players

사용되지 않는 항목 표시

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

만들 수 없음
서비스

서비스에는 현재 연결된 섬네일Roblox 서버에 액세스하기 위한 개체가 포함되어 있습니다.또한 플레이스구성에 대한 정보도 포함합니다.서버에 연결되지 않은 플레이어에 대한 정보(캐릭터 모양, 친구 및 아바타 썸네일 등)를 검색할 수 있습니다.

요약

속성

메서드

이벤트

속성

BanningEnabled

복제되지 않음
스크립팅할 수 없음
병렬 읽기

금지 API를 구성하는 세 가지 Players 메서드(BanAsync(), UnbanAsync(), GetBanHistoryAsync())를 활성화하거나 비활성화합니다.이 속성은 스크립트할 수 없으며 Studio에서만 수정할 수 있습니다.

BubbleChat

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

이 속성은 거품 채팅이 활성화되었는지 여부를 나타냅니다. 그것은 Players:SetChatStyle() 메서드를 사용하여 열거형 Enum.ChatStyle에 설정됩니다.

이 채팅 모드가 활성화되면 게임은 화면 왼쪽 상단 모서리의 채팅 사용자 인터페이스에 채팅을 표시합니다.

다른 두 가지 채팅 모드가 있습니다, Players.ClassicChat 및 클래식과 버블 채팅이 모두 활성화된 채팅 모드.

CharacterAutoLoads

복제되지 않음
병렬 읽기

이 속성은 characters가 자동으로 재생성되는지 여부를 나타냅니다. 기본값은 true입니다.

이 속성이 비활성화되면 (false) 플레이어 characters 는 플레이어가 경험에 참여할 때를 포함하여 각 Player:LoadCharacter() 에 대해 Player 함수가 호출될 때까지 생성되지 않습니다.

경쟁적인 게임과 같이 플레이어가 게임 라운드가 끝날 때까지 재생성되지 않는 한정된 삶을 가진 경험에서 유용할 수 있습니다.

코드 샘플

This example demonstrates one possible usage of the Players.CharacterAutoLoads property.

The example below respawns all players in the game, if dead, once every 10 seconds. This means that players who die 1 second after all players respawn must wait 9 seconds until the script loads all Player.Character again.

First, this script removes a player's character when they die and the Humanoid.Died function fires. This is done so that the respawn loop that executes every 10 seconds reloads that player when it does not find the player's character in the Workspace.

To work as expected, this example should be run within a Script.

Player Respawn Timer

local Players = game:GetService("Players")
-- Set CharacterAutoLoads to false
Players.CharacterAutoLoads = false
-- Remove player's character from workspace on death
Players.PlayerAdded:Connect(function(player)
while true do
local char = player.CharacterAdded:Wait()
char.Humanoid.Died:Connect(function()
char:Destroy()
end)
end
end)
-- Respawn all dead players once every 10 seconds
while true do
local players = Players:GetChildren()
-- Check if each player is dead by checking if they have no character, if dead load that player's character
for _, player in pairs(players) do
if not workspace:FindFirstChild(player.Name) then
player:LoadCharacter()
end
end
-- Wait 10 seconds until next respawn check
task.wait(10)
end

ClassicChat

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

클래식 채팅이 활성화되었는지 여부를 나타냅니다. 이 속성은 Players:SetChatStyle() 메서드를 사용하여 열거형 Enum.ChatStyle에 의해 설정됩니다.

이 채팅 모드가 활성화되면 게임은 발신자의 머리 위에 있는 거품에 채팅을 표시합니다.

다른 두 가지 채팅 모드가 있습니다, Players.BubbleChat 및 클래식과 버블 채팅이 모두 활성화된 채팅 모드.

LocalPlayer

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

이 읽기 전용 속성은 클라이언트가 경험을 실행하고 있는 Player에 대해 참조합니다.

이 속성은 클라이언트에서 실행되기 때문에 클라이언트에 필요한 LocalScriptsModuleScripts에만 정의되어 있습니다.서버에서, Script 개체가 코드를 실행하는 서버에서, 이 속성은 nil입니다.

MaxPlayers

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

이 속성은 서버에 있을 수 있는 최대 플레이어 수를 결정합니다.이 속성은 크리에이터 대시보드의 특정 플레이스설정 또는 게임 설정을 통해서만 설정할 수 있습니다.

PreferredPlayers

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

이 속성은 Roblox의 매치메이커가 서버를 채울 플레이어 수를 나타냅니다.이 숫자는 경험에서 지원하는 최대 플레이어 수(Players.MaxPlayers)보다 작을 것입니다.

RespawnTime

병렬 읽기

이 속성은 Players.CharacterAutoLoads가 true이면 플레이어가 재생성되는 데 걸리는 시간, 초를 제어합니다. 기본값은 5.0초입니다.

경험의 유형에 따라 재생성에 걸리는 시간을 변경하려고 하지만 플레이어를 개별적으로 처리하고 싶지 않은 경우 유용합니다.

이 속성은 내부에서 에 설정할 수 있지만, Studio의 Explorer 창에서 직접 설정하는 것이 더 쉽습니다.

UseStrafingAnimations

스크립팅할 수 없음
병렬 읽기

메서드

Chat

()
플러그인 보안

이 함수는 로컬 플레이어가 지정된 메시지를 채팅하게 합니다.이 항목이 보호되어 있으므로 Script 또는 LocalScript 사용하려고 시도하면 오류가 발생합니다.

대신, 사용자 지정 채팅 시스템이나 채팅에 액세스가 필요한 시스템을 생성할 때 Chat 서비스의 Chat:Chat() 기능을 대신 사용할 수 있습니다.

매개 변수

message: string

메시지가 채팅됩니다.

기본값: ""

반환

()

코드 샘플

This example demonstrates that the Players:Chat() function executes without error if using the Command Bar or a Plugin (assuming the local player can chat freely) and errors if executed in a Script.

Players:Chat

-- Command bar
game:GetService("Players"):Chat("Hello, world!") --Results in 'Hello, world!' appearing in the Chat log under your Player's name.
-- Script
local Players = game:GetService("Players")
Players:Chat("Hello, world!") --Errors

GetPlayerByUserId

병렬 쓰기

이 함수는 주어진 UserId와 일치하는 하나의 각 Player 에서 검색하여 Players 에서 모든 Player.UserId 을 찾습니다.그러한 플레이어가 존재하지 않으면 단순히 nil 을 반환합니다.다음 함수와 동일합니다:


local Players = game:GetService("Players")
local function getPlayerByUserId(userId)
for _, player in Players:GetPlayers() do
if player.UserId == userId then
return player
end
end
end

이 메서드는 구매자의 UserId를 포함하는 테이블을 제공하는 MarketplaceService.ProcessReceipt를 사용하여 개발자 제품의 구매자를 찾는 데 유용합니다. 플레이어 개체 자체에 대한 참조가 아니라.대부분의 게임은 제품을 부여하기 위해 플레이어에 대한 참조가 필요합니다.

매개 변수

userId: number

플레이어의 Player.UserId가 지정되었습니다.

기본값: ""

반환

코드 샘플

Players:GetPlayerByUserId

local Players = game:GetService("Players")
local player = Players:GetPlayerByUserId(1)
if player then
print("Player with userId 1 is in this server! Their name is: " .. player.Name)
else
print("Player with userId 1 is not in this server!")
end

The following code sample:

  • Sets up the ProcessReceipt callback function to handle the purchase of two developer products for an experience.
  • Checks for and records purchases using a GlobalDataStore called PurchaseHistory.
  • Properly returns PurchaseGranted if the transaction completes successfully, or if the function detects that the purchase has already been granted using the PurchaseHistory data store.
ProcessReceipt Callback

local MarketplaceService = game:GetService("MarketplaceService")
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
-- Data store setup for tracking purchases that were successfully processed
local purchaseHistoryStore = DataStoreService:GetDataStore("PurchaseHistory")
-- Table setup containing product IDs and functions for handling purchases
local productFunctions = {}
-- ProductId 123123 for a full heal
productFunctions[123123] = function(_receipt, player)
-- Logic for the player buying a full heal
if player.Character and player.Character:FindFirstChild("Humanoid") then
-- Heal the player to full health
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
-- Indicate a successful purchase
return true
end
end
-- ProductId 456456 for 100 gold
productFunctions[456456] = function(_receipt, player)
-- Logic for player buying 100 gold
local stats = player:FindFirstChild("leaderstats")
local gold = stats and stats:FindFirstChild("Gold")
if gold then
gold.Value = gold.Value + 100
-- Indicate a successful purchase
return true
end
end
-- The core 'ProcessReceipt' callback function
local function processReceipt(receiptInfo)
-- Check the data store to determine if the product was already granted
local playerProductKey = receiptInfo.PurchaseId
local purchased = false
local success, result, errorMessage
success, errorMessage = pcall(function()
purchased = purchaseHistoryStore:GetAsync(playerProductKey)
end)
-- If the purchase is recorded, the product was already granted
if success and purchased then
return Enum.ProductPurchaseDecision.PurchaseGranted
elseif not success then
error("Data store error:" .. errorMessage)
end
-- Update the purchase record
local success, isPurchaseRecorded = pcall(function()
return purchaseHistoryStore:UpdateAsync(playerProductKey, function(alreadyPurchased)
if alreadyPurchased then
return true
end
-- Find the player who made the purchase in the server
local player = Players:GetPlayerByUserId(receiptInfo.PlayerId)
if not player then
-- The player probably left the game
-- If the player returns, the callback is called again
return nil
end
local handler = productFunctions[receiptInfo.ProductId]
local success, result = pcall(handler, receiptInfo, player)
-- Do not record the purchase if granting the product failed
if not success or not result then
error(
"Failed to process a product purchase for ProductId: "
.. tostring(receiptInfo.ProductId)
.. " Player: "
.. tostring(player)
.. " Error: "
.. tostring(result)
)
return nil
end
-- Record the transaction in purchaseHistoryStore
return true
end)
end)
if not success then
error("Failed to process receipt due to data store error.")
return Enum.ProductPurchaseDecision.NotProcessedYet
elseif isPurchaseRecorded == nil then
-- Did not update the value in the data store
return Enum.ProductPurchaseDecision.NotProcessedYet
else
-- IMPORTANT: Tell Roblox that the game successfully handled the purchase
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
-- Set the callback; this can only be done once by one script on the server!
MarketplaceService.ProcessReceipt = processReceipt

GetPlayerFromCharacter

이 함수는 지정된 Player 에 연결된 Player.Character 또는 찾을 수 없는 경우 nil 을 반환합니다.다음 함수와 동일합니다:


local function getPlayerFromCharacter(character)
for _, player in game:GetService("Players"):GetPlayers() do
if player.Character == character then
return player
end
end
end

이 메서드는 플레이어의 캐릭터에서 일부 이벤트가 발생할 때 자주 사용됩니다(예: Class.Humanoid``Class.Humanoid.Died|dying ).그러한 이벤트는 플레이어 개체를 직접 참조하지 않을 수 있지만, 이 메서드는 쉬운 액세스를 제공합니다.이 함수의 역은 플레이어의 캐릭터를 가져오는 것으로 설명할 수 있습니다.이를 수행하려면 단순히 캐릭터 속성에 액세스하십시오.

매개 변수

character: Model

플레이어를 가져오려는 캐릭터 인스턴스.

기본값: ""

반환

코드 샘플

Players:GetPlayerFromCharacter

Players:GetPlayerFromCharacter

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local PLAYER_NAME = "Nightriff"
local character = Workspace:FindFirstChild(PLAYER_NAME)
local player = Players:GetPlayerFromCharacter(character)
if player then
print(`Player {player.Name} ({player.UserId}) is in the game`)
else
print(`Player {PLAYER_NAME} is not in the game!`)
end

GetPlayers

Instances
병렬 쓰기

이 메서드는 현재 연결된 모든 Player 개체의 테이블을 반환합니다.그것은 동일한 방식으로 작동하며 는 그것이 단지 아래에서 발견된 개체만 반환한다는 점을 제외하고는요.for 루프와 함께 사용하면 게임의 모든 플레이어를 반복하는 데 유용합니다.


local Players = game:GetService("Players")
for _, player in Players:GetPlayers() do
print(player.Name)
end

Players.PlayerAdded에 연결하는 스크립트는 종종 게임에 연결하는 모든 플레이어를 처리하려고 합니다.이 메서드는 이미 연결된 플레이어를 반복하는 데 유용하며 PlayerAdded 발사하지 않을 것입니다.이 방법을 사용하면 플레이어를 놓치지 않습니다!


local Players = game:GetService("Players")
local function onPlayerAdded(player)
print("Player: " .. player.Name)
end
for _, player in Players:GetPlayers() do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)

반환

Instances

서버의 모든 플레이어가 포함된 테이블.

코드 샘플

This code sample listens for players spawning and gives them Sparkles in their head. It does this by defining two functions, onPlayerSpawned and onPlayerAdded.

Give Sparkles to Everyone

local Players = game:GetService("Players")
local function onCharacterAdded(character)
-- Give them sparkles on their head if they don't have them yet
if not character:FindFirstChild("Sparkles") then
local sparkles = Instance.new("Sparkles")
sparkles.Parent = character:WaitForChild("Head")
end
end
local function onPlayerAdded(player)
-- Check if they already spawned in
if player.Character then
onCharacterAdded(player.Character)
end
-- Listen for the player (re)spawning
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

SetChatStyle

()
플러그인 보안

이 함수는 BubbleChat와 ClassicChat가 사용되는지 여부를 설정하고 TeamChat과 Chat에 사용할 Enum.ChatStyle을 알려줍니다.이 항목이 보호되어 있으므로 Script 또는 LocalScript 에서 사용하려고 하면 오류가 발생합니다.

이 함수는 게임에서 채팅 모드를 설정할 때 내부적으로 사용됩니다.

매개 변수

지정된 채팅 스타일이 설정되었습니다.

기본값: "Classic"

반환

()

코드 샘플

This example demonstrates that the Players:SetChatStyle() function executes without error if using the Command Bar or a Plugin and errors if executed in a LocalScript.

When executed in the Command Bar, this code sets the chat style to Classic using the Enum.ChatStyle enum.

Setting a Player's Chat Style

-- Command bar
game.Players:SetChatStyle(Enum.ChatStyle.Classic) -- Set's chat style to Classic
-- LocalScript
local Players = game:GetService("Players")
Players:SetChatStyle(Enum.ChatStyle.Classic) -- Errors

TeamChat

()
플러그인 보안

이 함수는 Players.LocalPlayer 채팅에 지정된 메시지를 표시하여 동일한 팀의 사용자만 볼 수 있도록 합니다.이 항목이 보호되어 있으므로 Script 또는 LocalScript 에서 사용하려고 하면 오류가 발생합니다.

이 함수는 Players.LocalPlayer가 팀에 메시지를 보낼 때 내부적으로 사용됩니다.

매개 변수

message: string

채팅되는 메시지.

기본값: ""

반환

()

코드 샘플

This example demonstrates that the Players:TeamChat() function executes without error if using the Command Bar or a Plugin and errors if executed in a LocalScript.

When executed in the Command Bar, the function sends the specified message to all players on the same Team as the Players.LocalPlayer.

Sending Team Chat

-- Command bar
game.Players:TeamChat("Hello World") -- Sends a "Hello World" message to all players on the local player's team
-- LocalScript
local Players = game:GetService("Players")
Players:TeamChat("Hello World") -- Errors

BanAsync

()
생성

방법은 경험의 가이드라인을 위반하는 사용자를 쉽게 금지할 수 있게 해줍니다.금지 기간, 의심되는 대체 계정으로의 금지 전파 및 사용 가이드라인에 따라 금지된 사용자에게 메시지를 제공할 수 있습니다.모든 사용자에게 액세스 가능한 곳에 경험 규칙을 게시하고 이의 신청수 있는 방법을 제공해야 합니다.이 메서드는 Studio에서 전환할 수 있는 Players.BanningEnabled 속성에 의해 활성화되고 비활성화됩니다.

금지 및 메시징

금지된 사용자는 즉시 퇴거되고 경험에 다시 참여하지 못합니다.그들은 금지 시간과 귀하의 DisplayReason 에 남은 시간을 표시하는 오류 모달이 표시되는 오류가 발생합니다.Roblox의 백엔드 시스템은 지정한 플레이스모든 서버의 플레이어를 퇴거합니다.DisplayReason 최대 길이 400자로 제한되며 텍스트 필터가 적용됩니다.허용 가능한 모달 텍스트에 대한 자세한 정보는 금지 메시징을 참조하십시오.

장소와 우주

기본적으로 금지는 해당 우주 내의 모든 장소로 확장됩니다.이 API가 호출되는 장소에만 금지를 제한하려면 ApplyToUniversefalse로 구성합니다.그러나 사용자가 우주의 시작 장소에서 금지되면 전체 우주에서 사용자가 제외되는 효과가 있지만, 일반적인 금지가 적용되는지 여부에 관계없이 말입니다.

대체 계정

사용자는 종종 다른 계정이나 대체 계정 또는 alt 계정이라고 알려진 여러 계정에서 플레이하며, 때로는 계정 금지를 우회하기 위해 사용됩니다.차단된 사용자를 계속 유지하는 데 도움이 되도록, 이 API의 기본 동작은 차단된 원본 계정에서 의심되는 알트 계정 중 하나로 모든 금지를 전파합니다.에서 로 구성하여 대체 계정에 대한 금지 전파를 끌 수 있습니다.

금지 기간

모든 위반이 동일하지는 않으므로 모든 금지가 동일한 길이가 아닌 경우가 많습니다.이 API를 사용하면 Duration 필드로 일시 정지기간을 초 단위로 구성할 수 있습니다.This API lets you configure the duration of the 일시 정지, in seconds, with the field.영구 금지를 지정하려면 필드를 -1로 설정하십시오.또한 사용자의 금지 기록에 따라 금지 기간을 동적으로 구성하려고 Players:GetBanHistoryAsync()를 사용하여 쿼리할 수도 있습니다.예를 들어, 금지 수, 이전 금지의 기간 또는 빌드 논리를 PrivateReason 에 저장하는 노트의 길이가 최대 1000자이고 텍스트가 필터링되지 않는 경우를 고려할 수 있습니다.PrivateReason 노트는 클라이언트와 결코 공유되지 않으며 공격자로부터 안전하다고 간주할 수 있습니다.

오류 및 속도 제한

이 메서드는 제한되고 실패할 수 있는 백엔드 서비스에 대한 HTTP 호출을 트리거합니다.이 API를 하나 이상의 UserId로 호출하는 경우, 이 메서드는 각 ID에 대해 HTTP 호출을 시도합니다.그런 다음 모든 오류 메시지를 집계하고 쉼표로 구분된 목록으로 결합합니다.예를 들어, 이 메서드가 5명의 사용자에게 호출되고 2와 4를 가진 사용자에 대한 요청이 실패하면 다음 오류 메시지가 표시됩니다:

HTTP failure for UserId 2: Timedout, HTTP 504 (Service unavailable) failure for UserId 4: Service exception

메시지는 항상 HTTP 오류인 경우 failure for UserId {}를 포함합니다.

클라이언트 측 요건

사용자 금지와 관련된 위험으로 인해 이 메서드는 백엔드 경험 서버(클라이언트 측 호출은 오류가 발생함)에서만 호출할 수 있습니다.스튜디오에서 공동 작품중이거나 팀 테스트 중에 이 API를 테스트할 수 있지만, 금지는 프로덕션에 적용되지 않습니다.

이 API는 사용자 제한 오픈 클라우드 API를 사용합니다. 이러한 API를 사용하여 타사 응용 프로그램에서 금지를 관리할 수 있습니다.

매개 변수

config: Dictionary
  • UserIds (필수; 배열) — 금지될 플레이어의 UserIds 배열의 최대 크기는 50 입니다.

  • ApplyToUniverse (옵션; 부울) — 금지가 경험 우주 내의 모든 장소로 퍼지는지 여부. 기본값은 true 입니다.

  • Duration (필수; 정수) — 일시 정지기간, 초 단위.영구 금지는 -1의 값을 가져야 합니다.0 및 모든 다른 부정 값은 유효하지 않은.

  • DisplayReason (필수; 문자열) — 사용자가 경험에 참여하려고 하지만 실패할 때 표시되는 메시지.최대 문자열 길이는 400입니다.

  • PrivateReason (필수; 문자열) — 사용자의 금지 기록을 쿼리할 때 반환되는 내부 메시징. 최대 문자열 길이는 1000입니다.

  • ExcludeAltAccounts (옵션; 부울) — 언제 true , Roblox는 alt 계정을 금지하려고 하지 않습니다. 기본값은 false 입니다.

기본값: ""

반환

()

코드 샘플

The following example bans a user with a duration calculated from their ban history, scoped to the entire universe and all of the user's alternate accounts.

Banning Users

local Players = game:GetService("Players")
if shouldBeBanned(player) then
local banHistoryPages = Players:GetBanHistoryAsync(player.UserId)
local duration = getNextBanDuration(banHistoryPages) -- Creator-implemented logic
local config: BanConfigType = {
UserIds = { player.UserId },
Duration = duration,
DisplayReason = "You violated community guideline #5",
PrivateReason = "Put anything here that the user should not know but is helpful for your records",
ExcludeAltAccounts = false,
ApplyToUniverse = true,
}
local success, err = pcall(function()
return Players:BanAsync(config)
end)
print(success, err)
end

CreateHumanoidModelFromDescription

생성

전달된 HumanoidDescription에 지정된 모든 것을 갖춘 캐릭터 모델을 반환하고, rigType에 의해 R6 또는 R15로 지정됩니다.

매개 변수

description: HumanoidDescription

반환된 문자의 모양을 지정합니다.

기본값: ""

반환된 문자가 R6 또는 R15인지 여부를 지정합니다.

기본값: ""
assetTypeVerification: Enum.AssetTypeVerification

자산 유형 확인은 이 함수가 모델을 로드할지 여부를 결정합니다(비카탈리스 자산을 로드하지 않으려면 항상으로 설정해야 함).

기본값: "Default"

반환

인간형 캐릭터 모델.

코드 샘플

This code sample creates a Humanoid Model from the passed in HumanoidDescription and parents the Model to the Workspace.

Create Humanoid Model From Description

game.Players:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15).Parent =
game.Workspace

CreateHumanoidModelFromUserId

생성

패스된 ID에 의해 지정된 사용자의 아바타와 일치하도록 장착된 모든 것을 갖춘 캐릭터 모델 설정을 반환합니다.여기에는 해당 캐릭터가 현재 R6 또는 R15인지 여부가 포함됩니다.

매개 변수

userId: number

Roblox 사용자의 아이디. (사용자 ID는 사용자 프로필의 숫자 e.g www.roblox.com/users/1/profile)입니다.

기본값: ""

반환

인간형 캐릭터 모델.

코드 샘플

This code sample creates a Humanoid Model to match the avatar of the passed in User ID, and parents the Model to the Workspace.

Create Humanoid Model From A User ID

game.Players:CreateHumanoidModelFromUserId(1).Parent = game.Workspace

GetBanHistoryAsync

생성

경험의 우주 내에서 사용자의 금지 및 해제 기록을 검색합니다.이 메서드는 BanHistoryPages에서 상속된 인스턴스를 반환합니다. Pages .이 메서드는 Studio에서 전환할 수 있는 Players.BanningEnabled 속성에 의해 활성화되고 비활성화됩니다.

이 함수 호출은 프로덕션 게임 서버에서만 성공하고 클라이언트 장치 또는 Studio에서는 성공하지 않습니다.

이 API는 사용자 제한 오픈 클라우드 API를 사용합니다. 이러한 API를 사용하여 타사 응용 프로그램에서 금지를 관리할 수 있습니다.

매개 변수

userId: number
기본값: ""

반환

반환 참조는 BanHistoryPages에 참조하십시오.

GetCharacterAppearanceInfoAsync

생성

이 함수는 Roblox 웹사이트에서 플레이어의 아바타(장비 무시)에 대한 정보를 사전 형식으로 반환합니다.이 메서드에서 설명하는 자산을 실제로 로드하는 GetCharacterAppearanceAsync 와 혼동되지 않아야 합니다.InsertService:LoadAsset()를 사용하여 플레이어의 아바타에 사용되는 자산을 로드할 수 있습니다.반환된 사전의 구조는 다음과 같습니다: The structure of the returned dictionary is as follows:


<th>유형</th>
<th>설명</th>
</tr>
</thead>
<tr>
<td><code>자산</code></td>
<td>테이블(아래 참조)</td>
<td>장착된 자산(모자, 신체 부위 등)을 설명합니다</td>
</tr>
<tr>
<td><code>바디 색상</code></td>
<td>테이블(아래 참조)</td>
<td>각 사지에 대한 BrickColor 값을 설명합니다</td>
</tr>
<tr>
<td><code>바디컬러3s</code></td>
<td>테이블(아래 참조)</td>
<td>보디컬러와 완벽하게 일치하지 않을 수 있는 각 사지의 Color3 인스턴스를 설명합니다</td>
</tr>
<tr>
<td><code>기본 바지 적용</code></td>
<td>부울</td>
<td>기본 바지가 적용되는지 여부를 설명합니다</td>
</tr>
<tr>
<td><code>기본 셔츠 적용됨</code></td>
<td>부울</td>
<td>기본 셔츠가 적용되는지 여부를 설명합니다</td>
</tr>
<tr>
<td><code>감정 표현</code></td>
<td>테이블(아래 참조)</td>
<td>장착된 감정 표현 애니메이션을 설명합니다</td>
</tr>
<tr>
<td><code>플레이어 아바타 유형</code></td>
<td>문자열</td>
<td>R15 또는 R6</td>
</tr>
<tr>
<td><code>저울</code></td>
<td>테이블(아래 참조)</td>
<td>다양한 바디 스케일링 요소를 설명합니다</td>
</tr>
이름
자산 서브테이블

표는 플레이어가 현재 장착한 자산을 설명하는 다음 키가 포함된 테이블 배열입니다:


<th>유형</th>
<th>설명</th>
</tr>
</thead>
<tr>
<td><code>id</code></td>
<td>번호</td>
<td>장착된 자산의 자산 ID</td>
</tr>
<tr>
<td><code>자산 유형</code></td>
<td>테이블</td>
<td>이름 과 아이디 필드가 있는 테이블, 각각 장착된 자산 유형("모자", "얼굴" 등)을 설명하는</td>
</tr>
<tr>
<td><code>이름</code></td>
<td>문자열</td>
<td>장착된 자산의 이름</td>
</tr>
이름
저울 하위 테이블

scales 테이블에는 다음 키가 있으며 각각 하나의 Humanoid 확장 속성에 해당하는 숫자가 있습니다: bodyType , head , height , proportion , depth , width .

바디 색상 하위 테이블

bodyColors 테이블에는 다음 키가 있으며 각각 BrickColor ID 번호에 해당하는 숫자로 BrickColor.new(id) 와 사용할 수 있습니다: leftArmColorId , torsoColorId , rightArmColorId , headColorId , leftLegColorId , rightLegColorId .

매개 변수

userId: number

지정된 플레이어의 * uid.

기본값: ""

반환

특정 사용자의 캐릭터 모양 정보가 포함된 사전.

코드 샘플

Sometimes it is best to see an example of the returned dictionary structure in pure Lua. Here is one such example of a player whose avatar uses a package and wears several hats. Can you guess who it is?

Example Return Character Appearance Dictionary

local result = {
playerAvatarType = "R15",
defaultPantsApplied = false,
defaultShirtApplied = false,
scales = {
bodyType = 0,
head = 1,
height = 1.05,
proportion = 0,
depth = 0.92,
width = 0.85,
},
bodyColors = {
leftArmColorId = 1030,
torsoColorId = 1001,
rightArmColorId = 1030,
headColorId = 1030,
leftLegColorId = 1001,
rightLegColorId = 1001,
},
assets = {
{
id = 1031492,
assetType = {
name = "Hat",
id = 8,
},
name = "Striped Hat",
},
{
id = 13062491,
assetType = {
name = "Face Accessory",
id = 42,
},
name = "Vision Française ",
},
{
id = 16598440,
assetType = {
name = "Neck Accessory",
id = 43,
},
name = "Red Bow Tie",
},
{
id = 28999228,
assetType = {
name = "Face",
id = 18,
},
name = "Joyous Surprise",
},
{
id = 86896488,
assetType = {
name = "Shirt",
id = 11,
},
name = "Expensive Red Tuxedo Jacket",
},
{
id = 86896502,
assetType = {
name = "Pants",
id = 12,
},
name = "Expensive Red Tuxedo Pants",
},
{
id = 376530220,
assetType = {
name = "Left Arm",
id = 29,
},
name = "ROBLOX Boy Left Arm",
},
{
id = 376531012,
assetType = {
name = "Right Arm",
id = 28,
},
name = "ROBLOX Boy Right Arm",
},
{
id = 376531300,
assetType = {
name = "Left Leg",
id = 30,
},
name = "ROBLOX Boy Left Leg",
},
{
id = 376531703,
assetType = {
name = "Right Leg",
id = 31,
},
name = "ROBLOX Boy Right Leg",
},
{
id = 376532000,
assetType = {
name = "Torso",
id = 27,
},
name = "ROBLOX Boy Torso",
},
},
}
print(result)

GetFriendsAsync

생성

GetFriends 함수는 지정된 모든 사용자의 친구에 대한 정보가 포함된 객체를 반환합니다.FriendPages 개체 내의 항목은 다음 필드가 있는 테이블입니다:


<th>유형</th>
<th>설명</th>
</tr>
</thead>
<tr>
<td>Id</td>
<td>int64</td>
<td>친구의 사용자 ID</td>
</tr>
<tr>
<td>사용자명</td>
<td>문자열</td>
<td>친구의 사용자 이름</td>
</tr>
<tr>
<td>표시 이름</td>
<td>문자열</td>
<td>친구의 <code>Class.Player.DisplayName|디스플레이 이름</code>.</td>
</tr>
이름

코드 샘플을 보면 모든 플레이어의 친구를 반복하는 쉬운 방법을 알 수 있습니다.

매개 변수

userId: number

지정된 플레이어의 사용자 ID.

기본값: ""

반환

코드 샘플

This code sample loads the Player.UserId of the player whose username is provided at the top of the script by using Players:GetUserIdFromNameAsync(). Then, it gets a FriendPages object by calling Players:GetFriendsAsync() and iterates over each entry using the iterPageItems function. The username of each friend is stored in a table, then printed at the end.

Print Roblox Friends

local Players = game:GetService("Players")
local USERNAME = "Cozecant"
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum = pagenum + 1
end
end)
end
-- First, get the user ID of the player
local userId = Players:GetUserIdFromNameAsync(USERNAME)
-- Then, get a FriendPages object for their friends
local friendPages = Players:GetFriendsAsync(userId)
-- Iterate over the items in the pages. For FriendPages, these
-- are tables of information about the friend, including Username.
-- Collect each username in a table
local usernames = {}
for item, _pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
end
print("Friends of " .. USERNAME .. ": " .. table.concat(usernames, ", "))

GetHumanoidDescriptionFromOutfitId

생성

특정 의상ID에 대한 HumanoidDescription을 반환하여 의상의 부품/색상/애니메이션 등으로 설정됩니다.의상은 사용자가 만든 의상일 수도 있고, Roblox가 만든 패키지의 의상일 수도 있습니다.

매개 변수

outfitId: number

HumanoidDescription가 검색된 의상의 ID.

기본값: ""

반환

패스된 의상ID에 대한 사양으로 초기화된 휴머노이드 설명.

코드 샘플

Shows how to get the HumanoidDescription for bundle 799 (Fishman).

Get HumanoidDescription From Outfit ID

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local function getOutfitId(bundleId)
if bundleId <= 0 then
return
end
local info = game.AssetService:GetBundleDetailsAsync(bundleId)
if not info then
return
end
for _, item in pairs(info.Items) do
if item.Type == "UserOutfit" then
return item.Id
end
end
return nil
end
local function getHumanoidDescriptionBundle(bundleId)
local itemId = getOutfitId(bundleId)
if itemId and itemId > 0 then
return Players:GetHumanoidDescriptionFromOutfitId(itemId)
end
return nil
end
local humanoidDescription = getHumanoidDescriptionBundle(799)
local humanoidModel = Players:CreateHumanoidModelFromDescription(humanoidDescription, Enum.HumanoidRigType.R15)
humanoidModel.Parent = Workspace

GetHumanoidDescriptionFromUserId

생성

패스된 ID에 의해 지정된 사용자의 아바타에 장착된 모든 것을 지정하는 HumanoidDescription을 반환합니다.또한 비늘과 바디 색상을 포함합니다.

매개 변수

userId: number

Roblox 사용자의 아이디. (사용자 ID는 사용자 프로필의 숫자 e.g www.roblox.com/users/1/profile)입니다.

기본값: ""

반환

사용자의 아바타 사양으로 초기화된 휴머노이드 설명.

코드 샘플

This code sample shows how to use GetHumanoidDescriptionFromUserId() to create a Humanoid Model.

Get HumanoidDescription From User ID

game.Players:CreateHumanoidModelFromDescription(
game.Players:GetHumanoidDescriptionFromUserId(1),
Enum.HumanoidRigType.R15
).Parent =
game.Workspace

GetNameFromUserIdAsync

생성

GetNameFromUserIdAsync Players 함수는 Roblox 웹사이트에 요청하여 지정된 UserId 의 계정 사용자 이름이 무엇인지 질문하는 쿼리를 보냅니다.

지정된 UserId로 계정이 없으면 이 메서드 오류가 발생합니다.그러한 계정이 존재하는지 확신할 수 없는 경우, 이 함수에 대한 호출을 pcall()로 래핑하는 것이 좋습니다.또한 동일한 사용자 ID로 나중에 호출할 수 있도록 결과를 수동으로 캐시할 수 있습니다.코드 샘플을 참조하여 자세히 알아보세요.

매개 변수

userId: number

플레이어의 Player.UserId가 지정되었습니다.

기본값: ""

반환

지정된 Player.UserId 의 사용자 이름.

코드 샘플

This code sample demonstrates using the Players:GetNameFromUserIdAsync() method to get a user's Player.Name from their Player.UserId.

Get Name from UserId

local Players = game:GetService("Players")
-- Example Data:
-- UserId: 118271 Name: "RobloxRulez"
-- UserId: 131963979 Name: "docsRule"
local nameOne = Players:GetNameFromUserIdAsync(118271)
local nameTwo = Players:GetNameFromUserIdAsync(131963979)
print(nameOne, nameTwo)
-- prints: "RobloxRulez docsRule"

This code sample demonstrates using the Players:GetNameFromUserIdAsync() method to get a user's Player.Name from their Player.UserId. Because GetNameFromUserIdAsync() yields, you can avoid calling it for the same Name using a table to store each UserId:Name pair found, called a cache. pcall() is used to catch the failure in case the Name doesn't exist.

Get Name from UserId using a cache

local Players = game:GetService("Players")
-- Create a table called 'cache' to store each 'Name' as they are found.
-- If we lookup a 'Name' using the same 'UserId', the 'Name' will come
-- from cache (fast) instead of GetNameFromUserIdAsync() (yields).
local cache = {}
function getNameFromUserId(userId)
-- First, check if the cache contains 'userId'
local nameFromCache = cache[userId]
if nameFromCache then
-- if a value was stored in the cache at key 'userId', then this 'nameFromCache'
-- is the correct Name and we can return it.
return nameFromCache
end
-- If here, 'userId' was not previously looked up and does not exist in the
-- cache. Now we need to use GetNameFromUserIdAsync() to look up the name
local name
local success, _ = pcall(function()
name = Players:GetNameFromUserIdAsync(userId)
end)
if success then
-- if 'success' is true, GetNameFromUserIdAsync() successfully found the
-- name. Store this name in the cache using 'userId' as the key so we
-- never have to look this name up in the future. Then return name.
cache[userId] = name
return name
end
-- If here, 'success' was false, meaning GetNameFromUserIdAsync()
-- was unable to find the 'name' for the 'userId' provided. Warn the user
-- this happened and then return nothing, or nil.
warn("Unable to find Name for UserId:", userId)
return nil
end
-- Example Data:
-- UserId: 118271 Name: "RobloxRulez"
-- UserId: 131963979 Name: "docsRule"
-- The first time a UserId is used, GetNameFromUserIdAsync() will be called
local nameOne = getNameFromUserId(118271)
local nameTwo = getNameFromUserId(131963979)
-- Because 118271 was previously used, get its Name from the cache
local nameOneQuick = getNameFromUserId(118271)
print(nameOne, nameTwo, nameOneQuick)
-- prints: "RobloxRulez docsRule RobloxRulez"

GetUserIdFromNameAsync

생성

이 함수는 Roblox 웹사이트에 쿼리를 보내어 지정된 Player.UserId 이름의 계정에 대해 Player가 무엇인지 질문합니다.

지정된 사용자 이름과 계정이 없는 경우 이 메서드 오류가 발생합니다.그러한 계정이 존재하는지 확신할 수 없는 경우, 이 함수에 대한 호출을 pcall()로 래핑하는 것이 좋습니다.또한 결과를 수동으로 캐시하여 나중에 동일한 사용자 이름으로 빠르게 호출할 수 있습니다.코드 샘플을 참조하여 자세히 알아보세요.

매개 변수

userName: string

지정된 플레이어의 사용자 이름.

기본값: ""

반환

이름이 지정된 사용자의 Player.UserId입니다.

코드 샘플

This code sample demonstrates using the Players:GetUserIdFromNameAsync() method to get a user's Player.UserId from their Player.Name.

Get UserId from Name

local Players = game:GetService("Players")
-- Example Data:
-- UserId: 118271 Name: "RobloxRulez"
-- UserId: 131963979 Name: "docsRule"
local userIdOne = Players:GetUserIdFromNameAsync("RobloxRulez")
local userIdTwo = Players:GetUserIdFromNameAsync("docsRule")
print(userIdOne, userIdTwo)
-- prints: "118271 131963979"

This code sample demonstrates using the Players:GetUserIdFromNameAsync() method to get a user's Player.UserId from their Player.Name. Because GetUserIdFromNameAsync() yields, you can avoid calling it for the same UserId using a table to store each Name:UserId pair found, called a cache. pcall() is used to catch the failure in case the UserId doesn't exist.

Get UserId from Name using a cache

local Players = game:GetService("Players")
-- Create a table called 'cache' to store each 'UserId' as they are found.
-- If we lookup a 'UserId' using the same 'Name', the 'UserId' will come
-- from cache (fast) instead of GetUserIdFromNameAsync() (yields).
local cache = {}
function getUserIdFromName(name)
-- First, check if the cache contains 'name'
local userIdFromCache = cache[name]
if userIdFromCache then
-- if a value was stored in the cache at key 'name', then this 'userIdFromCache'
-- is the correct UserId and we can return it.
return userIdFromCache
end
-- If here, 'name' was not previously looked up and does not exist in the
-- cache. Now we need to use GetUserIdFromNameAsync() to look up the userId
local userId
local success, _ = pcall(function()
userId = Players:GetUserIdFromNameAsync(name)
end)
if success then
-- if 'success' is true, GetUserIdFromNameAsync() successfully found the
-- userId. Store this userId in the cache using 'name' as the key so we
-- never have to look this userId up in the future. Then return userId.
cache[name] = userId
return userId
end
-- If here, 'success' was false, meaning GetUserIdFromNameAsync()
-- was unable to find the 'userId' for the 'name' provided. We can warn the
-- user this happened and then return nothing, or nil.
warn("Unable to find UserId for Name:", name)
return nil
end
-- Example Data:
-- UserId: 118271 Name: "RobloxRulez"
-- UserId: 131963979 Name: "docsRule"
-- The first time a Name is used, GetUserIdFromNameAsync() will be called
local userIdOne = getUserIdFromName("RobloxRulez")
local userIdTwo = getUserIdFromName("docsRule")
-- Because "RobloxRulez" was previously used, get its UserId from the cache
local userIdOneQuick = getUserIdFromName("RobloxRulez")
print(userIdOne, userIdTwo, userIdOneQuick)
-- prints: "118271 131963979 118271"

GetUserThumbnailAsync

생성

이 함수는 플레이어의 아바타의 이미지 콘텐츠 URL을 반환하며, 원하는 이미지 크기로 열거된 및 원하는 유형으로 열거된 열거된 형식입니다.또한 이미지가 사용 준비가 되었는지를 설명하는 부울을 반환합니다.

대부분 이 메서드는 경험에서 사용자 아바타 사진을 표시하기 위해 ImageLabel.Image 또는 Decal.Texture 와 함께 사용됩니다.

매개 변수

userId: number

플레이어의 Player.UserId가 지정되었습니다.

기본값: ""
thumbnailType: Enum.ThumbnailType

A Enum.ThumbnailType 섬네일것.

기본값: ""
thumbnailSize: Enum.ThumbnailSize

A Enum.ThumbnailSize 썸네일의 크기를 지정하는 것.

기본값: ""

반환

지정된 매개 변수에 따라 사용자 썸네일의 콘텐츠 URL을 포함하는 튜플, 이미지가 사용 준비가 되었는지 여부를 설명하는 부울.

코드 샘플

This code sample displays the current player's thumbnail in a parent ImageLabel by using Players:GetUserThumbnailAsync() and setting the Image() property as well as its Size().

Display Player Thumbnail

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local PLACEHOLDER_IMAGE = "rbxassetid://0" -- replace with placeholder image
-- fetch the thumbnail
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
-- set the ImageLabel's content to the user thumbnail
local imageLabel = script.Parent
imageLabel.Image = (isReady and content) or PLACEHOLDER_IMAGE
imageLabel.Size = UDim2.new(0, 420, 0, 420)

UnbanAsync

()
생성

Players:BanAsync() 또는 사용자 제한 오픈 클라우드 API에서 금지된 플레이어를 금지합니다.이 메서드는 Studio에서 전환할 수 있는 Players.BanningEnabled 속성에 의해 활성화되고 비활성화됩니다.

Like Players:BanAsync() , 이 메서드는 사용자를 대량으로 금지 해제할 수 있는 config 사전을 가져옵니다.이렇게 하면 차단이 해제된 사용자와 차단된 범위가 구성됩니다.

금지 해제는 동일한 ApplyToUniverse범위의 금지에만 적용됩니다.예를 들어, 에 설정된 금지를 로 해제하면 이전에 에 설정된 금지가 무효화되지 않습니다.즉, 우주 수준 금지는 장소 수준 일시 정지무효화하지 않습니다.반대의 경우도 마찬가지입니다.

이 메서드는 제한되고 실패할 수 있는 백엔드 서비스에 대한 HTTP 호출을 트리거합니다.여러 사용자 ID로 이 API를 호출하는 경우 이 메서드는 각 사용자 ID에 대해 이 HTTP 호출을 시도합니다.그런 다음 모든 오류 메시지를 집계하고 쉼표로 구분된 목록으로 결합합니다.예를 들어, 이 메서드가 5 : 및 사용자 2와 4에 대한 요청이 실패하면 다음 오류 메시지가 나타납니다: 메시지는 항상 HTTP 오류인 경우 포함됩니다.유효하고 무효한 사용자 ID를 모두 전달하는 경우 정의되지 않은 동작, 즉일부 네트워크 요청이 모든 입력이 유효성 검사되기 전에 성공할 수 있기 때문에 양의 숫자가 아닌 a UserId

사용자 금지와 관련된 위험으로 인해 이 메서드는 백엔드 게임 서버에서만 호출할 수 있습니다.클라이언트 측 호출은 오류가 발생합니다.Studio, 팀 생성 및 팀 테스트에서 이 API를 테스트할 수 있지만 밴은 프로덕션에 적용되지 않습니다.이 함수 호출은 프로덕션 게임 서버에서만 금지 요청을 시도하고 스튜디오 테스트에서는 시도하지 않습니다.그러나 모든 입력 유효성 검사 단계는 Studio에서 여전히 작동합니다.

이 API는 사용자 제한 오픈 클라우드 API를 사용합니다. 이러한 API를 사용하여 타사 응용 프로그램에서 금지를 관리할 수 있습니다.

매개 변수

config: Dictionary

<th>유형</th>
<th>설명</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>사용자 ID</code></td>
<td>배열</td>
<td>경험(들)에 강제로 허용될 UserIDs(들). 최대 크기는 <code>50</code>입니다.</td>
</tr>
<tr>
<td><code>애플리케이션 대 유니버스 적용</code></td>
<td>부울</td>
<td>이 우주 내의 모든 장소에 금지 해제를 전파합니다.</td>
</tr>
</tbody>
이름
기본값: ""

반환

()

코드 샘플

The following un-bans a user, as well as another unrelated account with UserId 789.

Unbanning Users

local Players = game:GetService("Players")
if shouldBeUnbanned(player) then
local config: UnbanConfigType = {
UserIds = { player.UserId, 789 },
ApplyToUniverse = false,
}
local success, err = pcall(function()
return Players:UnbanAsync(config)
end)
print(success, err)
end

이벤트

PlayerAdded

이 이벤트는 플레이어가 게임에 들어갈 때 발생합니다.플레이어가 게임에 참여할 때 이벤트를 발생시키는 데 사용되며, 플레이어의 저장된 GlobalDataStore

이는 플레이어가 게임을 떠날 때 발생하는 Players.PlayerRemoving 이벤트와 함께 사용할 수 있습니다.예를 인스턴스, 새로운 플레이어가 게임에 참여하거나 게임을 떠날 때마다 메시지를 인쇄하려는 경우:


local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
end)
Players.PlayerRemoving:Connect(function(player)
print(player.Name .. " left the game!")
end)

플레이어의 캐릭터가 게임에 추가되거나 제거되는 시기를 추적하려는 경우, 플레이어가 재생성되거나 사망할 때와 같이, Player.CharacterAddedPlayer.CharacterRemoving 함수를 사용할 수 있습니다.

플레이 모드에서 스크립트가 연결되는 것을 기다리기 전에 플레이어가 생성되므로 이 이벤트는 플레이 모드에서 예상대로 작동하지 않습니다.이 경우와 플레이어가 게임에 들어온 후 스크립트가 추가되는 경우를 처리하려면, 플레이어의 입장을 처리할 수 있는 onPlayerAdded() 함수를 만들어 플레이어의 입장을 처리할 수 있습니다.

매개 변수

player: Player

게임에 참여한 플레이어의 인스턴스.


코드 샘플

This example will print "A player has entered: " followed by the name of the player that enters/joins a game every time a player joins.

Players.PlayerAdded

local Players = game:GetService("Players")
local function onPlayerAdded(player)
print("A player has entered: " .. player.Name)
end
Players.PlayerAdded:Connect(onPlayerAdded)

PlayerMembershipChanged

이 이벤트는 게임 서버가 플레이어의 회원권이 변경되었음을 인식하면 발생합니다.그러나 서버는 프리미엄 모달이 닫힌 후에만 멤버십을 확인하고 업데이트할 것입니다 .따라서 사용자가 게임 외부에서 프리미엄 을 구매하는 경우를 고려하려면 여전히 Premium구매를 요청해야 하며, 이렇게 하면 게임 서버가 업그레이드되었다는 메시지를 표시하고 이 이벤트가 트리거됩니다.

Premium에 대해 자세히 알아보고 경험에 통합하고 참여 기반 지불 시스템으로 수익을 창출하려면 영agement-Based Payouts를 참조하십시오.

참조하세요:

매개 변수

player: Player

코드 샘플

The function in the code sample runs after the game server confirms a player's membership has changed. It demonstrates how you can grant players access to Premium benefits (or revoke them) when their membership status changes.

Handling Premium Membership Changes

local Players = game:GetService("Players")
local function grantPremiumBenefits(player)
-- Grant the player access to Premium-only areas, items, or anything you can imagine!
print("Giving", player, "premium benefits!")
end
local function playerAdded(player)
if player.MembershipType == Enum.MembershipType.Premium then
grantPremiumBenefits(player)
end
end
local function playerMembershipChanged(player)
print("Received event PlayerMembershipChanged. New membership = " .. tostring(player.MembershipType))
if player.MembershipType == Enum.MembershipType.Premium then
grantPremiumBenefits(player)
end
end
Players.PlayerAdded:Connect(playerAdded)
Players.PlayerMembershipChanged:Connect(playerMembershipChanged)

PlayerRemoving

플레이어 제거 이벤트는 게임을 떠나기 바로 전에 발생합니다 Player.이 이벤트는 ChildRemovedPlayers 에서 발생하기 전에 발생하며, Instance.DescendantRemoving 와 비슷하게 동작합니다.실제 제거 전에 발생하기 때문에, 를 사용하여 플레이어 데이터를 저장하는 데 유용합니다.

이는 플레이어가 게임에 참여할 때 발생하는 Player.PlayerAdded 이벤트와 함께 사용할 수 있습니다.예를 인스턴스, 새로운 플레이어가 게임에 참여하거나 게임을 떠날 때마다 메시지를 인쇄하려면:


local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
print(player.Name .. " joined the game!")
end)
Players.PlayerRemoving:Connect(function(player)
print(player.Name .. " left the game!")
end)

플레이어의 캐릭터가 게임에 추가되거나 제거되는 시기를 추적하려는 경우, 플레이어가 재생성되거나 사망할 때와 같이, Player.CharacterAddedPlayer.CharacterRemoving 함수를 사용할 수 있습니다.

매개 변수

player: Player

게임을 떠나는 플레이어의 인스턴스.


코드 샘플

This code will print "A player has left: ", followed by the player's name, every time a player leaves:

Players.PlayerRemoving

local Players = game:GetService("Players")
local function onPlayerRemoving(player)
print("A player has left: " .. player.Name)
end
Players.PlayerRemoving:Connect(onPlayerRemoving)

UserSubscriptionStatusChanged

이 이벤트는 게임 서버가 특정 구독의 사용자 상태가 변경되었음을 인식하면 발생합니다.서버는 구독 구매 모달이 닫힌 후에만 상태를 확인하고 업데이트하려고 시도합니다( ).게임 플레이 중에 사용자가 구독을 구매하는 경우를 고려하려면 여전히 구독을 구매하도록 요청해야 하며, 메시지는 사용자에게 이미 구독되었음을 알려주고, 모달을 닫은 후에 게임 서버는 구독 상태를 업데이트하고 이 이벤트를 트리거합니다.

서버 스크립트만 이 이벤트를 받는다는 점에 유의하십시오.

매개 변수

user: Player

구독 상태가 변경된 사용자.

subscriptionId: string

상태 변경이 있는 구독의 ID.