表情符號是可以使用聊天指令(「/e 歡呼」)或存取任何體驗右上角的「表情符號選單」(「/e 歡呼」)來訪問的表達性角色動畫。所有使用者都有 access to 默认表情,例如 跳舞 , 點 和 歡呼 。額外的虛擬人偶表情可以從 市場 購買和裝備。
在您的經體驗中,您可以執行以下表情自訂:
- 開啟並關閉 使用者的表情選單程式化。
- 從使用者的選單中新增或移除 個表情選項。
- 停用菜單的存取。
- 播放 一個動作,瞄準特定使用者角色。
表情選單
您可以手動開啟和關閉使用者的表情選單,自訂選單以顯示特定表情,或完全禁用選單。
開啟和關閉
要手動開啟或關閉玩家的表情選單,請使用boolean值為真或假的GuiService:SetEmotesMenuOpen()來打開或關閉表情選單。
以下代碼示例將為使用者開啟表情選單:
-- 開啟表情選單local GuiService = game:GetService("GuiService")GuiService:SetEmotesMenuOpen(true)
如果您需要檢查是否打開了表情選單,請呼叫 GuiService:GetEmotesMenuOpen() 。這會返回一個指示選單當前狀態的 boolean 。
添加和移除表情符號
通過設置目錄中的表情並裝備表情到 Humanoid 來自定義表情選單。使用 HumanoidDescription:SetEmotes() 方法設置表情符號,並使用 HumanoidDescription:SetEquippedEmotes() 裝備最多 8 個表情符號到表情選單。
在 資料夾內使用以下代碼示例來設置和裝備體驗中的表情符號:
local Players = game:GetService("Players")local humanoid = Players.LocalPlayer.Character.Humanoidlocal humanoidDescription = humanoid.HumanoidDescription-- 在表中設置自訂表情符號local emoteTable = {["Hello"] = {3576686446},["Stadium"] = {3360686498},["Tilt"] = {3360692915},["Shrug"] = {3576968026},["Salute"] = {3360689775},["Point"] = {3576823880}}humanoidDescription:SetEmotes(emoteTable)-- 按特定順序裝備表情符號local equippedEmotes = {"Hello", "Stadium", "Tilt", "Shrug", "Salute", "Point"}humanoidDescription:SetEquippedEmotes(equippedEmotes)
停用
使用 StarterGui:SetCoreGuiEnabled() 關閉表情選單。禁用表情選單不會防止使用聊天指令進行表情。
以下示例代碼將禁用表情選單:
local StarterGui = game:GetService("StarterGui")StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.EmotesMenu, false)
除了禁用菜單外,您還可以通過設置 StarterPlayer.UserEmotesEnabled 屬性內的用戶擁有的表情符號載入關閉來禁用用戶擁有的表情符號載入 StarterPlayer > 角色 到 假 。此特定屬性只能在工作室中設置,並且無法由腳本設置。
播放表情
要手動播放角色擁有的 HumanoidDescription 表情,請呼叫 Humanoid:PlayEmote(),傳送動作字串名稱。此呼叫將返回真值以表示已成功播放表情符號,否則為假值。
使用以下代碼示例播放肩膀動作表情:
local Players = game:GetService("Players")local humanoid = Players.LocalPlayer.Character.Humanoidhumanoid:PlayEmote("Shrug")