Empty
Empty
Empty
Players 是一個跟蹤遊戲中所有當前玩家的服務。
Empty
Empty
Empty
它管理玩家資料,並提供處理玩家相關事件的功能,例如當玩家加入或離開遊戲時。
Roblox Studio
Empty
Empty
Empty
local Players = game:GetService("Players")
local function printAllPlayers()
for _, player in pairs(Players:GetPlayers()) do
print("Player Name: " .. player.Name)
end
end
printAllPlayers()
Empty
Empty
Empty
local Players = game:GetService("Players")
local function onPlayerAdded(player)
print(player.Name .. " has joined the game.")
end
local function onPlayerRemoving(player)
print(player.Name .. " has left the game.")
end
Players.PlayerAdded:Connect(onPlayerAdded)
Players.PlayerRemoving:Connect(onPlayerRemoving)
Empty
Empty
Empty
Backpack | 儲存玩家在庫存中的工具和物品。這些可以透過 StarterPack 或動態地透過腳本加入。 |
PlayerGui | 包含玩家的使用者介面(UI)元素。該資料夾包含從 StarterGui 複製的 UI 元素的副本。 |
PlayerScripts | 儲存於客戶端為玩家執行的腳本。從 StarterPlayerScripts 複製的腳本會被放置在此處。 |