เรียนรู้
Engine Class
Player

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


สรุป
วิธีการ
GetFriendsOnline(maxFriends: number):{any}
เลิกใช้แล้ว
GetRankInGroup(groupId: number):number
เลิกใช้แล้ว
GetRankInGroupAsync(groupId: number):number
เลิกใช้แล้ว
GetRoleInGroup(groupId: number):string
เลิกใช้แล้ว
GetRoleInGroupAsync(groupId: number):string
เลิกใช้แล้ว
IsBestFriendsWith(userId: User):boolean
เลิกใช้แล้ว
IsFriendsWith(userId: User):boolean
เลิกใช้แล้ว
isFriendsWith(userId: User):boolean
เลิกใช้แล้ว
IsInGroup(groupId: number):boolean
เลิกใช้แล้ว
Kick(message: string):()
LoadBoolean(key: string):boolean
เลิกใช้แล้ว
loadBoolean(key: string):boolean
เลิกใช้แล้ว
LoadCharacter():()
เลิกใช้แล้ว
LoadCharacterAppearance(assetInstance: Instance):()
เลิกใช้แล้ว
LoadCharacterWithHumanoidDescription(humanoidDescription: HumanoidDescription,assetTypeVerification: Enum.AssetTypeVerification):()
เลิกใช้แล้ว
LoadInstance(key: string):Instance
เลิกใช้แล้ว
loadInstance(key: string):Instance
เลิกใช้แล้ว
LoadNumber(key: string):number
เลิกใช้แล้ว
loadNumber(key: string):number
เลิกใช้แล้ว
LoadString(key: string):string
เลิกใช้แล้ว
loadString(key: string):string
เลิกใช้แล้ว
Move(walkDirection: Vector3,relativeToCamera: boolean):()
RequestStreamAroundAsync(position: Vector3,timeOut: number):()
SaveBoolean(key: string,value: boolean):()
เลิกใช้แล้ว
saveBoolean(key: string,value: boolean):()
เลิกใช้แล้ว
SaveInstance(key: string,value: Instance):()
เลิกใช้แล้ว
saveInstance(key: string,value: Instance):()
เลิกใช้แล้ว
SaveNumber(key: string,value: number):()
เลิกใช้แล้ว
saveNumber(key: string,value: number):()
เลิกใช้แล้ว
SaveString(key: string,value: string):()
เลิกใช้แล้ว
saveString(key: string,value: string):()
เลิกใช้แล้ว
SetAccountAge(accountAge: number):()
WaitForDataReady():boolean
เลิกใช้แล้ว
waitForDataReady():boolean
เลิกใช้แล้ว
สมาชิกที่ได้รับทอด

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
AccountAge
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.AccountAge:number

AutoJumpEnabled
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.AutoJumpEnabled:boolean
ตัวอย่างโค้ด
ปิด/เปิดการกระโดดโดยอัตโนมัติ
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local button = script.Parent
local function update()
-- อัปเดตข้อความบนปุ่ม
if player.AutoJumpEnabled then
button.Text = "การกระโดดโดยอัตโนมัติเปิดอยู่"
else
button.Text = "การกระโดดโดยอัตโนมัติปิดอยู่"
end
-- สะท้อนคุณสมบัติในตัวละครของผู้เล่น หากพวกเขามี
if player.Character then
local human = player.Character:FindFirstChild("Humanoid")
if human then
human.AutoJumpEnabled = player.AutoJumpEnabled
end
end
end
local function onActivated()
-- สลับการกระโดดโดยอัตโนมัติ
player.AutoJumpEnabled = not player.AutoJumpEnabled
-- อัปเดตทุกอย่างอื่น
update()
end
button.Activated:Connect(onActivated)
update()

CameraMaxZoomDistance
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.CameraMaxZoomDistance:number

CameraMinZoomDistance
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.CameraMinZoomDistance:number

CameraMode
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.CameraMode:Enum.CameraMode
ตัวอย่างโค้ด
เล่นในมุมมองบุคคลที่หนึ่ง
local Players = game:GetService("Players")
local player = Players.LocalPlayer
player.CameraMode = Enum.CameraMode.LockFirstPerson

CanLoadCharacterAppearance
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.CanLoadCharacterAppearance:boolean

Character
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.Character:Model

CharacterAppearance
เลิกใช้แล้ว

CharacterAppearanceId
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.CharacterAppearanceId:number

DataComplexity
เลิกใช้แล้ว

DataReady
เลิกใช้แล้ว

DevCameraOcclusionMode
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.DevCameraOcclusionMode:Enum.DevCameraOcclusionMode

DevComputerCameraMode
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.DevComputerCameraMode:Enum.DevComputerCameraMovementMode

DevComputerMovementMode
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.DevComputerMovementMode:Enum.DevComputerMovementMode

DevEnableMouseLock
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.DevEnableMouseLock:boolean

DevTouchCameraMode
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.DevTouchCameraMode:Enum.DevTouchCameraMovementMode

DevTouchMovementMode
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.DevTouchMovementMode:Enum.DevTouchMovementMode

DisplayName
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.DisplayName:string

FollowUserId
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.FollowUserId:number
ตัวอย่างโค้ด
การแจ้งเตือนเมื่อมีคนติดตาม
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = player:WaitForChild("PlayerGui")
local function onPlayerAdded(newPlayer)
if newPlayer.FollowUserId == player.UserId then
local textLabel = Instance.new("TextLabel")
textLabel.Parent = screenGui
textLabel.Text = "คุณได้รับการติดตามเข้าสู่เกมนี้โดย " .. newPlayer.Name .. "!"
task.delay(3, function()
if textLabel then
textLabel:Destroy()
end
end)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)

GameplayPaused
ซ่อนอยู่
การรักษาความปลอดภัยที่เข้าถึงไม่ได้
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.GameplayPaused:boolean

HasRobloxSubscription
การรักษาความปลอดภัยของ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.HasRobloxSubscription:boolean
ตัวอย่างโค้ด
ตรวจสอบสถานะการสมัครสมาชิก Roblox
local Players = game:GetService("Players")
local player = Players.LocalPlayer
if player.HasRobloxSubscription then
-- มอบเนื้อหาหรือสิทธิพิเศษเฉพาะสมาชิก
end

HasVerifiedBadge
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.HasVerifiedBadge:boolean

HealthDisplayDistance
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.HealthDisplayDistance:number

InputLatency
การรักษาความปลอดภัยของ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.InputLatency:number

LocaleId
ซ่อนอยู่
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.LocaleId:string

MembershipType
เลิกใช้แล้ว

NameDisplayDistance
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.NameDisplayDistance:number

Neutral
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.Neutral:boolean

PartyId
ซ่อนอยู่
ไม่ซ้ำ
การรักษาความปลอดภัยของ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.PartyId:string
ตัวอย่างโค้ด
ผู้เล่น.PartyId
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local partyId = player.PartyId
if partyId ~= "" then
print("ผู้เล่นอยู่ในกลุ่มที่มี ID: " .. partyId)
else
print("ผู้เล่นไม่ได้อยู่ในกลุ่ม")
end
player:GetPropertyChangedSignal("PartyId"):Connect(function()
if player.PartyId ~= "" then
print("ผู้เล่นเข้าร่วมกลุ่มที่มี ID: " .. player.PartyId)
else
print("ผู้เล่นออกจากกลุ่ม")
end
end)
end)

ReplicationFocus
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.ReplicationFocus:Instance

RespawnLocation
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.RespawnLocation:SpawnLocation
ตัวอย่างโค้ด
เปลี่ยนจุดเกิดเมื่อสัมผัส
local Players = game:GetService("Players")
local function addSpawn(spawnLocation)
-- ฟังการสัมผัสที่จุดเกิด
spawnLocation.Touched:Connect(function(hit)
local character = hit:FindFirstAncestorOfClass("Model")
if character then
local player = Players:GetPlayerFromCharacter(character)
if player and player.RespawnLocation ~= spawnLocation then
local humanoid = character:FindFirstChildOfClass("Humanoid")
-- ตรวจสอบให้แน่ใจว่าตัวละครยังไม่ตาย
if humanoid and humanoid:GetState() ~= Enum.HumanoidStateType.Dead then
print("ตั้งค่าจุดเกิด")
player.RespawnLocation = spawnLocation
end
end
end
end)
end
local firstSpawn
-- มองหาสิ่งที่เกิดขึ้นใน workspace
for _, descendant in pairs(workspace:GetDescendants()) do
if descendant:IsA("SpawnLocation") then
if descendant.Name == "FirstSpawn" then
firstSpawn = descendant
end
addSpawn(descendant)
end
end
local function playerAdded(player)
player.RespawnLocation = firstSpawn
end
-- ฟังผู้เล่นใหม่
Players.PlayerAdded:Connect(playerAdded)
-- ผ่านผู้เล่นที่มีอยู่
for _, player in pairs(Players:GetPlayers()) do
playerAdded(player)
end

StepIdOffset
การรักษาความปลอดภัยของ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.StepIdOffset:number

Team
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.Team:Team

TeamColor
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.TeamColor:BrickColor

ThirdPartyTextChatRestrictionStatus
อ่านอย่างเดียว
ไม่ซ้ำ
การรักษาความปลอดภัยของสคริปต์ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.ThirdPartyTextChatRestrictionStatus:Enum.ChatRestrictionStatus

User
การรักษาความปลอดภัยของ Roblox
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.User:User

UserId
อ่านพร้อมๆ กัน
ความสามารถ: Players
Player.UserId:number
ตัวอย่างโค้ด
รหัสผู้เล่น
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print(player.UserId)
end
Players.PlayerAdded:Connect(onPlayerAdded)
ระบบข้อมูลไปยังกระดานผู้นำ
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local goldDataStore = DataStoreService:GetDataStore("Gold")
local STARTING_GOLD = 100
local function onPlayerAdded(player)
local playerKey = "Player_" .. player.UserId
local leaderstats = Instance.new("IntValue")
leaderstats.Name = "leaderstats"
local gold = Instance.new("IntValue")
gold.Name = "Gold"
gold.Parent = leaderstats
local success, result = pcall(function()
return goldDataStore:GetAsync(playerKey) or STARTING_GOLD
end)
if success then
gold.Value = result
else
-- ไม่สามารถดึงข้อมูลได้
warn(result)
end
leaderstats.Parent = player
end
Players.PlayerAdded:Connect(onPlayerAdded)

userId
เลิกใช้แล้ว

วิธีการ
AddReplicationFocus
ความสามารถ: Players
Player:AddReplicationFocus(part:BasePart):()
พารามิเตอร์
ส่งค่ากลับ
()

ClearCharacterAppearance
ความสามารถ: Players
Player:ClearCharacterAppearance():()
ส่งค่ากลับ
()
ตัวอย่างโค้ด
วิธีการล้างรูปลักษณ์ของตัวละคร
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local function onChildRemoved(child)
print(child.ClassName, "ถูกลบออกจากตัวละคร")
end
character.ChildRemoved:Connect(onChildRemoved)
player:ClearCharacterAppearance()
--> BodyColors ถูกลบออกจากตัวละคร
--> ShirtGraphic ถูกลบออกจากตัวละคร
--> เสื้อถูกลบออกจากตัวละคร
--> กางเกงถูกลบออกจากตัวละคร
--> CharacterMesh ถูกลบออกจากตัวละคร
--> หมวกถูกลบออกจากตัวละคร
--> เสื้อถูกลบออกจากตัวละคร

ClearCachedAvatarAppearance
ความสามารถ: AvatarAppearance, Players
Player:ClearCachedAvatarAppearance():()
ส่งค่ากลับ
()

DistanceFromCharacter
ความสามารถ: Players
Player:DistanceFromCharacter(point:Vector3):number
พารามิเตอร์
point:Vector3
ส่งค่ากลับ
ตัวอย่างโค้ด
การวัดระยะทางระหว่างผู้เล่นกับตำแหน่ง
local Players = game:GetService("Players")
for _, player in pairs(Players:GetPlayers()) do
print(player:DistanceFromCharacter(Vector3.new(0, 0, 0)))
end

GetFriendsOnline
เลิกใช้แล้ว

GetFriendsOnlineAsync
ผลตอบแทน
ความสามารถ: Players, Social
Player:GetFriendsOnlineAsync(maxFriends:number):{any}
พารามิเตอร์
maxFriends:number
ค่าเริ่มต้น: 200
ส่งค่ากลับ
ตัวอย่างโค้ด
รับรายการการเชื่อมต่อออนไลน์
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local success, result = pcall(player.GetFriendsOnlineAsync, player, 10)
if success then
for _, friend in pairs(result) do
print(friend.UserName)
end
else
warn("ไม่สามารถดึงผู้เล่นออนไลน์ได้: " .. result)
end

GetFriendsWhoPlayedAsync
ผลตอบแทน
ความสามารถ: Players, Social
Player:GetFriendsWhoPlayedAsync():{any}
ส่งค่ากลับ

GetJoinData
ความสามารถ: Players
Player:GetJoinData():Dictionary
ส่งค่ากลับ
ตัวอย่างโค้ด
ติดตามแหล่งที่มาของการเข้าชม
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local analyticsStore = DataStoreService:GetDataStore("Analytics")
local ALLOWED_SOURCES = {
"twitter",
"youtube",
"discord",
}
local function onPlayerAdded(player)
local source = player:GetJoinData().LaunchData
-- ตรวจสอบว่าแหล่งที่มาที่ให้มานั้นถูกต้อง
if source and table.find(ALLOWED_SOURCES, source) then
-- อัปเดตข้อมูลใน store เพื่อติดตามความนิยมของแหล่งที่มานั้น
local success, result = pcall(analyticsStore.IncrementAsync, analyticsStore, source)
if success then
print(player.Name, "เข้าร่วมจาก", source, "- รวมทั้งหมด:", result)
else
warn("ล้มเหลวในการบันทึกแหล่งที่เข้าร่วม: " .. result)
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
ตัวสร้าง URL อ้างอิง
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local DIRECT_JOIN_URL = "https://www.roblox.com/games/start?placeId=%d&launchData=%s"
local textBox = script.Parent
local function generateReferralURL(player)
return DIRECT_JOIN_URL:format(game.PlaceId, player.UserId)
end
local function highlightAll()
if -- หลบเลี่ยงการอัปเดตคุณสมบัติที่เกิดซ้ำ
textBox:IsFocused() and not (textBox.SelectionStart == 1 and textBox.CursorPosition == #textBox.Text + 1)
then
textBox.SelectionStart = 1
textBox.CursorPosition = #textBox.Text + 1
end
end
textBox.Focused:Connect(highlightAll)
textBox:GetPropertyChangedSignal("SelectionStart"):Connect(highlightAll)
textBox:GetPropertyChangedSignal("CursorPosition"):Connect(highlightAll)
textBox.TextEditable = false
textBox.ClearTextOnFocus = false
textBox.Text = generateReferralURL(player)
การใช้ตารางเป็นข้อมูลการเริ่มต้น
local HttpService = game:GetService("HttpService")
local DATA_CHARACTER_LIMIT = 200
local function encodeTableAsLaunchData(data)
-- แปลงตารางเป็นสตริง
local jsonEncodedData = HttpService:JSONEncode(data)
if #jsonEncodedData <= DATA_CHARACTER_LIMIT then
-- หลีกเลี่ยงอักขระที่อาจไม่ถูกต้อง เช่น ช่องว่าง
local urlEncodedData = HttpService:UrlEncode(jsonEncodedData)
return true, urlEncodedData
else
-- รายงานข้อผิดพลาดจากข้อจำกัดของอักขระ
return false, ("ตารางที่เข้ารหัสเกินขีดจำกัดอักขระ %d"):format(DATA_CHARACTER_LIMIT)
end
end
local sampleData = {
joinMessage = "สวัสดี!",
urlCreationDate = os.time(),
magicNumbers = {
534,
1337,
746733573,
},
}
local success, encodedData = encodeTableAsLaunchData(sampleData)
if success then
print(encodedData)
else
warn("ไม่สามารถเข้ารหัสข้อมูลการเริ่มต้นได้: " .. encodedData)
end
การถอดรหัสข้อมูลการเริ่มต้น JSON
local HttpService = game:GetService("HttpService")
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local launchData = player:GetJoinData().LaunchData
if launchData then
-- พยายามถอดรหัสข้อมูล
local success, result = pcall(HttpService.JSONDecode, HttpService, launchData)
if success then
print(player.Name, "เข้าร่วมด้วยข้อมูล:", result)
else
-- นี่อาจเกิดจากผู้ใช้ปรับแต่ง URL
warn("ไม่สามารถวิเคราะห์ข้อมูลการเริ่มต้นได้:" .. result)
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
ตัวอย่างข้อมูลการโทรศัพท์ของเซิร์ฟเวอร์
local Players = game:GetService("Players")
local approvedPlaceIds = { 1 } -- แทรก PlaceIds ที่ได้รับการอนุมัติมาที่นี่
local function isPlaceIdApproved(placeId)
for _, id in pairs(approvedPlaceIds) do
if id == placeId then
return true
end
end
return false
end
local function onPlayerAdded(player)
local joinData = player:GetJoinData()
-- ตรวจสอบว่าข้อมูลนี้ถูกส่งโดยสถานที่ที่ได้รับการอนุมัติ
if isPlaceIdApproved(joinData.SourcePlaceId) then
local teleportData = joinData.TeleportData
if teleportData then
local currentLevel = teleportData.currentLevel
print(player.Name .. " อยู่ที่ระดับ " .. currentLevel)
end
end
end
Players.PlayerAdded:Connect(onPlayerAdded)

GetMouse
ความสามารถ: Input, Players
Player:GetMouse():Mouse
ส่งค่ากลับ

GetNetworkPing
เขียนพร้อมๆ กัน
ความสามารถ: Players
Player:GetNetworkPing():number
ส่งค่ากลับ

GetRankInGroup
เลิกใช้แล้ว

GetRankInGroupAsync
เลิกใช้แล้ว

GetRoleInGroup
เลิกใช้แล้ว

GetRoleInGroupAsync
เลิกใช้แล้ว

HasAppearanceLoaded
ความสามารถ: Players
Player:HasAppearanceLoaded():boolean
ส่งค่ากลับ
ตัวอย่างโค้ด
ตรวจสอบว่ารูปลักษณ์ของผู้เล่นถูกโหลดหรือไม่
local Players = game:GetService("Players")
local function onPlayerAdded(player)
local loaded = player:HasAppearanceLoaded()
print(loaded)
while not loaded do
loaded = player:HasAppearanceLoaded()
print(loaded)
task.wait()
end
end
Players.PlayerAdded:Connect(onPlayerAdded)

IsBestFriendsWith
เลิกใช้แล้ว

IsFriendsWith
เลิกใช้แล้ว

isFriendsWith
เลิกใช้แล้ว

IsFriendsWithAsync
ผลตอบแทน
ความสามารถ: Players, Social
Player:IsFriendsWithAsync(userId:User):boolean
พารามิเตอร์
userId:User
ส่งค่ากลับ

IsInGroup
เลิกใช้แล้ว

IsInGroupAsync
ผลตอบแทน
ความสามารถ: Players, Groups
Player:IsInGroupAsync(groupId:number):boolean
พารามิเตอร์
groupId:number
ส่งค่ากลับ

IsVerified
ความสามารถ: Players
Player:IsVerified():boolean
ส่งค่ากลับ
ตัวอย่างโค้ด
การใช้ IsVerified
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print(player:IsVerified())
end
for _, player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)

Kick
ความสามารถ: Players, Consequences
Player:Kick(message:string):()
พารามิเตอร์
message:string
ส่งค่ากลับ
()

LoadBoolean
เลิกใช้แล้ว

loadBoolean
เลิกใช้แล้ว

LoadCharacter
เลิกใช้แล้ว

LoadCharacterAppearance
เลิกใช้แล้ว

LoadCharacterAsync
ผลตอบแทน
ความสามารถ: Players
Player:LoadCharacterAsync():()
ส่งค่ากลับ
()
ตัวอย่างโค้ด
ปิดการโหลดอัตโนมัติและจำลองการเกิดใหม่ของตัวละคร
local Players = game:GetService("Players")
local RESPAWN_DELAY = 5
Players.CharacterAutoLoads = false
local function onPlayerAdded(player)
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local function onDied()
task.wait(RESPAWN_DELAY)
player:LoadCharacterAsync()
end
humanoid.Died:Connect(onDied)
end
player.CharacterAdded:Connect(onCharacterAdded)
player:LoadCharacterAsync()
end
Players.PlayerAdded:Connect(onPlayerAdded)

LoadCharacterWithHumanoidDescription
เลิกใช้แล้ว

LoadCharacterWithHumanoidDescriptionAsync
ผลตอบแทน
ความสามารถ: Players
Player:LoadCharacterWithHumanoidDescriptionAsync(
humanoidDescription:HumanoidDescription, assetTypeVerification:Enum.AssetTypeVerification
):()
พารามิเตอร์
humanoidDescription:HumanoidDescription
assetTypeVerification:Enum.AssetTypeVerification
ค่าเริ่มต้น: "Default"
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การสร้างตัวละครด้วย HumanoidDescription
local Players = game:GetService("Players")
Players.CharacterAutoLoads = false
-- ฟังก์ชันนี้จะถูกเรียกเมื่อผู้เล่นเข้ามา
local function onPlayerAdded(player)
-- สร้างอธิบายของมนุษย์
local humanoidDescription = Instance.new("HumanoidDescription")
humanoidDescription.HatAccessory = "2551510151,2535600138"
humanoidDescription.BodyTypeScale = 0.1
humanoidDescription.ClimbAnimation = 619521311
humanoidDescription.Face = 86487700
humanoidDescription.GraphicTShirt = 1711661
humanoidDescription.HeadColor = Color3.new(0, 1, 0)
-- โหลดตัวละครด้วยคำอธิบายของมนุษย์
player:LoadCharacterWithHumanoidDescriptionAsync(humanoidDescription)
end
Players.PlayerAdded:Connect(onPlayerAdded)

LoadInstance
เลิกใช้แล้ว

loadInstance
เลิกใช้แล้ว

LoadNumber
เลิกใช้แล้ว

loadNumber
เลิกใช้แล้ว

LoadString
เลิกใช้แล้ว

loadString
เลิกใช้แล้ว

Move
ความสามารถ: Players
Player:Move(
walkDirection:Vector3, relativeToCamera:boolean
):()
พารามิเตอร์
walkDirection:Vector3
relativeToCamera:boolean
ค่าเริ่มต้น: false
ส่งค่ากลับ
()
ตัวอย่างโค้ด
การเคลื่อนที่ของผู้เล่นสัมพันธ์กับกล้องของพวกเขา
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
-- รอให้ตัวละครและมนุษย์ของผู้เล่นซึ่งต้องมีอยู่ก่อนที่จะเรียกใช้ :Move()
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
character:WaitForChild("Humanoid")
-- ผู้เล่นจะเคลื่อนที่จนกว่าพวกเขาจะอยู่ห่างจากตำแหน่งของกล้อง 50 สตูดในขณะรัน
localPlayer:Move(Vector3.new(0, 0, -50), true)

RemoveReplicationFocus
ความสามารถ: Players
Player:RemoveReplicationFocus(part:BasePart):()
พารามิเตอร์
ส่งค่ากลับ
()

RequestStreamAroundAsync
ผลตอบแทน
ความสามารถ: Players
Player:RequestStreamAroundAsync(
position:Vector3, timeOut:number
):()
พารามิเตอร์
position:Vector3
timeOut:number
ค่าเริ่มต้น: 0
ส่งค่ากลับ
()

SaveBoolean
เลิกใช้แล้ว

saveBoolean
เลิกใช้แล้ว

SaveInstance
เลิกใช้แล้ว

saveInstance
เลิกใช้แล้ว

SaveNumber
เลิกใช้แล้ว

saveNumber
เลิกใช้แล้ว

SaveString
เลิกใช้แล้ว

saveString
เลิกใช้แล้ว

SetAccountAge
การรักษาความปลอดภัยของปลั๊กอิน
ความสามารถ: Players
Player:SetAccountAge(accountAge:number):()
พารามิเตอร์
accountAge:number
ส่งค่ากลับ
()

SetSuperSafeChat
การรักษาความปลอดภัยของปลั๊กอิน
ความสามารถ: Players
Player:SetSuperSafeChat(value:boolean):()
พารามิเตอร์
value:boolean
ส่งค่ากลับ
()

WaitForDataReady
เลิกใช้แล้ว

waitForDataReady
เลิกใช้แล้ว

เหตุการณ์
CharacterAdded
ความสามารถ: Players
Player.CharacterAdded(character:Model):RBXScriptSignal
พารามิเตอร์
character:Model
ตัวอย่างโค้ด
การตรวจจับการเกิดและการหายไปของผู้เล่น
local Players = game:GetService("Players")
local function onCharacterAdded(character)
print(character.Name .. " ได้เกิดขึ้น")
end
local function onCharacterRemoving(character)
print(character.Name .. " กำลังหายไป")
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
player.CharacterRemoving:Connect(onCharacterRemoving)
end
Players.PlayerAdded:Connect(onPlayerAdded)
ตัวลบอุปกรณ์
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local function destroyAccessory(object)
if object:IsA("Hat") or object:IsA("Accessory") then
object:Destroy()
end
end
local function onCharacterAdded(character)
-- รอชั่วขณะก่อนที่จะลบอุปกรณ์เพื่อหลีกเลี่ยงการ
-- "บางสิ่งตั้งค่า ___ parent เป็น NULL อย่างไม่คาดคิด" เตือน
RunService.Stepped:Wait()
-- ตรวจสอบอุปกรณ์ที่มีอยู่ในตัวละครของผู้เล่น
for _, child in pairs(character:GetChildren()) do
destroyAccessory(child)
end
-- หมวกอาจถูกเพิ่มในตัวละครชั่วขณะหลังจาก
-- CharacterAdded เกิดขึ้น ดังนั้นเราจึงฟังเรื่องเหล่านั้นโดยใช้ ChildAdded
character.ChildAdded:Connect(destroyAccessory)
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)

CharacterAppearanceLoaded
ความสามารถ: Players
Player.CharacterAppearanceLoaded(character:Model):RBXScriptSignal
พารามิเตอร์
character:Model
ตัวอย่างโค้ด
ลบอุปกรณ์หลังจากโหลดเสร็จแล้ว
local Players = game:GetService("Players")
local function onPlayerAddedAsync(player)
local connection = player.CharacterAppearanceLoaded:Connect(function(character)
-- อุปกรณ์ทั้งหมดได้โหลดเสร็จแล้วในจุดนี้
local humanoid = character:FindFirstChildOfClass("Humanoid")
local numAccessories = #humanoid:GetAccessories()
print(("กำลังลบอุปกรณ์ %d ชิ้นสำหรับ %s"):format(numAccessories, player.Name))
humanoid:RemoveAccessories()
end)
-- ต้องแน่ใจว่าเราได้ตัดการเชื่อมต่อจากผู้เล่นหลังจากที่พวกเขาออก
-- เพื่อให้ผู้เล่นสามารถถูกเก็บขยะได้
player.AncestryChanged:Wait()
connection:Disconnect()
end
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAddedAsync, player)
end
Players.PlayerAdded:Connect(onPlayerAddedAsync)

CharacterRemoving
ความสามารถ: Players
Player.CharacterRemoving(character:Model):RBXScriptSignal
พารามิเตอร์
character:Model
ตัวอย่างโค้ด
การตรวจจับการเกิดและการหายไปของผู้เล่น
local Players = game:GetService("Players")
local function onCharacterAdded(character)
print(character.Name .. " ได้เกิดขึ้น")
end
local function onCharacterRemoving(character)
print(character.Name .. " กำลังหายไป")
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
player.CharacterRemoving:Connect(onCharacterRemoving)
end
Players.PlayerAdded:Connect(onPlayerAdded)

Chatted
ความสามารถ: Chat, Players
Player.Chatted(
message:string, recipient:Player
พารามิเตอร์
message:string
recipient:Player

Idled
ความสามารถ: Players
Player.Idled(time:number):RBXScriptSignal
พารามิเตอร์
time:number

OnTeleport
ความสามารถ: Players, Teleport
Player.OnTeleport(
teleportState:Enum.TeleportState, placeId:number, spawnName:string
พารามิเตอร์
teleportState:Enum.TeleportState
placeId:number
spawnName:string
ตัวอย่างโค้ด
ผู้เล่น.OnTeleport
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local playerOnTeleport = player
player.OnTeleport:Connect(function(teleportState, _placeId, _spawnName)
if teleportState == Enum.TeleportState.Started then
print("การโทรเลขเริ่มต้นแล้ว (" .. playerOnTeleport.Name .. ")")
elseif teleportState == Enum.TeleportState.WaitingForServer then
print("การโทรเลขรอเซิร์ฟเวอร์ (" .. playerOnTeleport.Name .. ")")
elseif teleportState == Enum.TeleportState.InProgress then
print("การโทรเลขกำลังดำเนินการ (" .. playerOnTeleport.Name .. ")")
elseif teleportState == Enum.TeleportState.Failed then
print("การโทรเลขล้มเหลว! (" .. playerOnTeleport.Name .. ")")
end
end)
end)

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ