Players

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่

ไม่สามารถสร้าง
บริการ

บริการ Players มีวัตถุ Player สำหรับลูกค้าที่เชื่อมต่ออยู่ในปัจจุบันกับเซิร์ฟเวอร์ Robloxนอกจากนี้ยังมีข้อมูลเกี่ยวกับการกำหนดค่าสถานที่มันสามารถดึงข้อมูลเกี่ยวกับผู้เล่นที่ไม่ได้เชื่อมต่อกับเซิร์ฟเวอร์ เช่น รูปลักษณ์ของตัวละคร เพื่อน และภาพรวมของอวตาร

สรุป

คุณสมบัติ

  • ไม่ซ้ำ
    ไม่สามารถเขียนสคริปต์
    อ่านพร้อมๆ กัน

    เปิดใช้งานหรือปิดใช้งานวิธีการสาม Players วิธี ( BanAsync() , UnbanAsync() และ GetBanHistoryAsync() ) ที่ประกอบขึ้นเป็น API การแบนคุณสมบัตินี้ไม่สามารถสคริปต์ได้และสามารถแก้ไขได้เฉพาะใน Studio

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    บ่งบอกว่าการแชทฟองอากาศถูกเปิดใช้งานหรือไม่ ตั้งค่าด้วยวิธี Players:SetChatStyle()

  • ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    บ่งบอกว่า characters จะเกิดใหม่โดยอัตโนมัติหรือไม่

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    บ่งบอกว่าจะมีการเปิดใช้งานการแชทแบบคลาสสิกหรือไม่; ตั้งโดยวิธี Players:SetChatStyle()

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    The Player ที่ LocalScript กําลังทํางานอยู่

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    จํานวนผู้เล่นสูงสุดที่สามารถอยู่ในเซิร์ฟเวอร์ได้

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    จํานวนผู้เล่นที่ต้องการสําหรับเซิร์ฟเวอร์

  • อ่านพร้อมๆ กัน

    ควบคุมจำนวนเวลาที่ใช้สำหรับตัวละครผู้เล่นที่จะเกิดใหม่

  • ไม่สามารถเขียนสคริปต์
    อ่านพร้อมๆ กัน

วิธีการ

  • Chat(message : string):()
    การรักษาความปลอดภัยของปลั๊กอิน

    ทำให้ผู้เล่นท้องถิ่นแชทข้อความที่กำหนดไว้

  • เขียนพร้อมๆ กัน

    ส่งคืน Player ด้วย UserId ที่กำหนดไว้หากพวกเขาอยู่ในเกม

  • คืนค่า Player ซึ่ง Player.Character อินสแตนซ์nil หากไม่พบได้

  • GetPlayers():Instances
    เขียนพร้อมๆ กัน

    คืนตารางของวัตถุทั้งหมดที่เชื่อมต่ออยู่ในปัจจุบัน Player อยู่

  • การรักษาความปลอดภัยของปลั๊กอิน

    ตั้งค่าว่า BubbleChat และ ClassicChat จะถูกใช้หรือไม่ และบอก TeamChat และ Chat สิ่งที่ต้องทำ

  • TeamChat(message : string):()
    การรักษาความปลอดภัยของปลั๊กอิน

    ทำให้ผู้เล่นท้องถิ่นแชทข้อความที่กำหนด ซึ่งจะมองเห็นได้เฉพาะผู้ใช้ในทีมเดียวกันเท่านั้น

  • BanAsync(config : Dictionary):()
    ผลตอบแทน

    ห้ามผู้ใช้จากประสบการณ์ของคุณด้วยตัวเลือกในการระบุระยะเวลา เหตุผล ว่าการแบนมีผลกับจักรวาลทั้งหมดหรือเพียงแค่สถานที่ปัจจุบันเท่านั้น และอื่นๆวิธีนี้เปิดใช้งานและปิดใช้งานโดยคุณสมบัติ Players.BanningEnabled ซึ่งคุณสามารถสลับได้ใน Studio

  • ผลตอบแทน

    ส่งคืนโมเดลตัวละครที่ติดตั้งทุกอย่างตามที่ระบุไว้ใน HumanoidDescription และเป็น R6 หรือ R15 ตามที่กำหนดโดย rigType

  • ผลตอบแทน

    คืนชุดตั้งค่าตัวละครที่มีทุกอย่างพร้อมสำหรับการจับคู่กับอวตารของผู้ใช้ที่ระบุโดยใช้ userId ที่ส่ง

  • ผลตอบแทน

    ดึงประวัติการแบนและยกเลิกการแบนของผู้ใช้ใดๆ ภายในจักรวาลประสบการณ์วิธีนี้เปิดใช้งานและปิดใช้งานโดยคุณสมบัติ Players.BanningEnabled ซึ่งคุณสามารถสลับได้ใน Studio

  • ผลตอบแทน

    ส่งคืนข้อมูลเกี่ยวกับรูปลักษณ์ของตัวละครของผู้ใช้ที่กำหนด

  • ผลตอบแทน

    ส่งคืนวัตถุ FriendPages ที่มีข้อมูลสำหรับเพื่อนของผู้เล่นทั้งหมดที่กำหนด

  • ส่งคืนคำอธิบายมนุษย์สำหรับชุดที่กำหนดซึ่งจะถูกตั้งค่าด้วยส่วน/สี/แอนิเมชั่นต่างๆของชุด

  • ส่งคืนคำอธิบายมนุษย์ที่ระบุถึงทุกอย่างที่ติดตั้งสำหรับอวตารของผู้ใช้ที่ระบุโดย userId ที่ส่ง

  • ผลตอบแทน

    ส่งคำถามไปยังเว็บไซต์ Roblox สําหรับชื่อผู้ใช้ของบัญชีที่มี UserId ที่กำหนด

  • ผลตอบแทน

    ส่งคำถามไปยังเว็บไซต์ Roblox สําหรับ userId ของบัญชีที่มีชื่อผู้ใช้ที่กำหนด

  • GetUserThumbnailAsync(userId : number,thumbnailType : Enum.ThumbnailType,thumbnailSize : Enum.ThumbnailSize):Tuple
    ผลตอบแทน

    คืน URL พิมพ์รวมถึงบูลีนที่อธิบายถึงว่าภาพพร้อมใช้งานหรือไม่

  • UnbanAsync(config : Dictionary):()
    ผลตอบแทน

    ยกเลิกการแบนผู้เล่นที่ถูกแบนจาก Players:BanAsync() หรือ Cloud APIPlayers.BanningEnabled ซึ่งคุณสามารถสลับได้ใน Studio

เหตุการณ์

  • เกิดไฟไหม้เมื่อผู้เล่นเข้าสู่เกม

  • ไฟเมื่อเซิร์ฟเวอร์เกมรู้ว่าสมาชิกของผู้เล่นเปลี่ยนแปลงแล้ว

  • เกิดไฟไหม้เมื่อผู้เล่นกำลังจะออกจากเกม

  • เกิดไฟไหม้เมื่อเซิร์ฟเวอร์เกมรู้ว่าสถานะของผู้ใช้สำหรับสมัครสมาชิกบางอย่างได้เปลี่ยนแปลง

คุณสมบัติ

BanningEnabled

ไม่ซ้ำ
ไม่สามารถเขียนสคริปต์
อ่านพร้อมๆ กัน

BubbleChat

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

CharacterAutoLoads

ไม่ซ้ำ
อ่านพร้อมๆ กัน

ตัวอย่างโค้ด

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

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

LocalPlayer

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

MaxPlayers

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

PreferredPlayers

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

RespawnTime

อ่านพร้อมๆ กัน

UseStrafingAnimations

ไม่สามารถเขียนสคริปต์
อ่านพร้อมๆ กัน

วิธีการ

Chat

()
การรักษาความปลอดภัยของปลั๊กอิน

พารามิเตอร์

message: string
ค่าเริ่มต้น: ""

ส่งค่ากลับ

()

ตัวอย่างโค้ด

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: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

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

GetPlayerFromCharacter

พารามิเตอร์

character: Model
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

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
เขียนพร้อมๆ กัน

ส่งค่ากลับ

Instances

ตัวอย่างโค้ด

ให้ประกายแสงแก่ทุกคน

local Players = game:GetService("Players")
local function onCharacterAdded(character)
-- ให้ประกายไฟบนหัวหากพวกเขายังไม่มี
if not character:FindFirstChild("Sparkles") then
local sparkles = Instance.new("Sparkles")
sparkles.Parent = character:WaitForChild("Head")
end
end
local function onPlayerAdded(player)
-- ตรวจสอบว่าพวกเขาได้เกิดขึ้นแล้วใน
if player.Character then
onCharacterAdded(player.Character)
end
-- ฟังผู้เล่น (รี) เกิดใหม่
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

SetChatStyle

()
การรักษาความปลอดภัยของปลั๊กอิน

พารามิเตอร์

ค่าเริ่มต้น: "Classic"

ส่งค่ากลับ

()

ตัวอย่างโค้ด

ตั้งสไตล์การแชทของผู้เล่น

-- แถบคําสั่ง
game.Players:SetChatStyle(Enum.ChatStyle.Classic) -- ตั้งสไตล์การแชทเป็นแบบคลาสสิก
-- สคริปท์ท้องถิ่น
local Players = game:GetService("Players")
Players:SetChatStyle(Enum.ChatStyle.Classic) -- Errors

TeamChat

()
การรักษาความปลอดภัยของปลั๊กอิน

พารามิเตอร์

message: string
ค่าเริ่มต้น: ""

ส่งค่ากลับ

()

ตัวอย่างโค้ด

ส่งการแชททีม

-- แถบคําสั่ง
game.Players:TeamChat("Hello World") -- ส่งข้อความ "สวัสดีชาวโลก" ไปยังผู้เล่นทุกคนในทีมผู้เล่นท้องถิ่น
-- สคริปท์ท้องถิ่น
local Players = game:GetService("Players")
Players:TeamChat("Hello World") -- Errors

BanAsync

()
ผลตอบแทน

พารามิเตอร์

config: Dictionary
ค่าเริ่มต้น: ""

ส่งค่ากลับ

()

ตัวอย่างโค้ด

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

ผลตอบแทน

พารามิเตอร์

description: HumanoidDescription
ค่าเริ่มต้น: ""
ค่าเริ่มต้น: ""
assetTypeVerification: Enum.AssetTypeVerification
ค่าเริ่มต้น: "Default"

ส่งค่ากลับ

ตัวอย่างโค้ด

สร้างโมเดลมนุษย์จากคำอธิบาย

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

CreateHumanoidModelFromUserId

ผลตอบแทน

พารามิเตอร์

userId: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

Create Humanoid Model From A User ID

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

GetBanHistoryAsync

ผลตอบแทน

พารามิเตอร์

userId: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

GetCharacterAppearanceInfoAsync

ผลตอบแทน

พารามิเตอร์

userId: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

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

ผลตอบแทน

พารามิเตอร์

userId: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

Print Roblox Connections

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 connections
local friendPages = Players:GetFriendsAsync(userId)
-- Iterate over the items in the pages. For FriendPages, these
-- are tables of information about the connection, including Username.
-- Collect each username in a table
local usernames = {}
for item, _pageNo in iterPageItems(friendPages) do
table.insert(usernames, item.Username)
end
print("Connections of " .. USERNAME .. ": " .. table.concat(usernames, ", "))

GetHumanoidDescriptionFromOutfitId

ผลตอบแทน

พารามิเตอร์

outfitId: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

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

ผลตอบแทน

พารามิเตอร์

userId: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

Get HumanoidDescription From User ID

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

GetNameFromUserIdAsync

ผลตอบแทน

พารามิเตอร์

userId: number
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

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"
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

ผลตอบแทน

พารามิเตอร์

userName: string
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

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"
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

ผลตอบแทน

พารามิเตอร์

userId: number
ค่าเริ่มต้น: ""
thumbnailType: Enum.ThumbnailType
ค่าเริ่มต้น: ""
thumbnailSize: Enum.ThumbnailSize
ค่าเริ่มต้น: ""

ส่งค่ากลับ

ตัวอย่างโค้ด

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

()
ผลตอบแทน

พารามิเตอร์

config: Dictionary
ค่าเริ่มต้น: ""

ส่งค่ากลับ

()

ตัวอย่างโค้ด

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

พารามิเตอร์

player: Player

ตัวอย่างโค้ด

Players.PlayerAdded

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

PlayerMembershipChanged

พารามิเตอร์

player: Player

ตัวอย่างโค้ด

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: Player

ตัวอย่างโค้ด

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