表情條

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

表情是任何社交體驗的核心組成部分。表情條 開發模組 的目標是提供玩家一個可輕鬆使用、可自訂的方式來促進有意義的社交互動。

模組使用

安裝

要在體驗中使用 EmoteBar 模組:

  1. 視圖標籤開啟工具箱,然後選擇 創作者商店 標籤。

    Toolbox toggle button in Studio
  2. 確保 模型 排序已選擇,然後單擊 查看全部 按鈕以獲得 類別

  3. 找到並點擊 開發模組 磚塊。

  4. 尋找 表情欄 模組,然後單擊它或拖放到 3D 視檢視中。

  5. 瀏覽器 窗口中,將整個 EmoteBar 模型移至 ServerScriptService 。執行體驗時,模組會分配到各種服務並開始運行。

配置

模組預先配置了 7 個表情,您可以使用自己的表情和顯示選項進行簡單的自訂。此外,如果玩家擁有以前 Roblox 事件的任何表情,例如 Lil Nas X、Royal Blood 或 Twenty One Pilots,這些表情將自動加入可用的表情列表。

  1. 服務器腳本服務 中,創建新的 Script 並將其重命名為 配置表情符號

  2. 將以下代碼貼到新的 配置表情符號 指令碼本中。useDefaultEmotes 設定的 false 覆蓋了預設表情符號,並讓您通過 setEmotes 函數定義自訂表情符號。

    腳本 - 配置表情符號

    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
    EmoteBar.configureServer({
    useDefaultEmotes = false,
    })
    EmoteBar.setEmotes({
    {
    name = "Hello",
    animation = "rbxassetid://3344650532",
    image = "rbxassetid://7719817462",
    defaultTempo = 1,
    },
    {
    name = "Applaud",
    animation = "rbxassetid://5915693819",
    image = "rbxassetid://7720292217",
    defaultTempo = 2,
    },
    })

巨型表情

當多名玩家在相同區域執行相同表情時,會形成 超級表情 。隨著越來越多的玩家加入,超級表情也會變得更大。隨著玩家停止表演動作,超級表情最終會縮小直至消失。

溫度

表動作的 速度 是當按鈕被點擊一次時播放的速度。表動作的預設速度由其 defaultTempo 決定。通過快速或慢速點擊按鈕來增加或減少表情的速度。

API 參考

類型

表情

每個表情都由以下鑰匙值對表示的辭典:

關鍵類型說明
name字串表情名稱,例如 "Shrug"
animation字串表情動畫的資產ID。
image字串使用者GUI的動作情圖像的資產ID。
defaultTempo數字播放表情動畫的預設速度因子。例如,2的速度將播放動畫的速度是正常速度的兩倍。必須大於 0。
isLockedbool是否將表情「鎖定」,以防啟用。

枚數

表情條。GUI類型

名稱總結
EmoteBar預設形式,在屏幕底部的欄位中顯示表情符號,分開成個別的「頁面」。
EmoteWheel當玩家單擊或點擊他們的玩家角色時,變體會在環中顯示表情符號。
本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.configureClient({
guiType = EmoteBar.GuiType.EmoteWheel,
})

功能

配置伺服器

配置伺服器(config: table)

通過以下鑰匙/值在 config 表中覆蓋預設服務器配置選項,來覆蓋預設服務器配置選項。此功能只能從 Script 呼叫,並且變更將自動複製到所有客戶端。

關鍵說明預設
useDefaultEmotes是否包含提供的預設表情符號。真的
useMegaEmotes啟用或停用 超級表情 功能。真的
emoteMinPlayers最少數量的玩家執行相同的表情來貢獻超級動作。3
emoteMaxPlayers最大玩家數量執行相同的表情來貢獻超級動作。50
playParticles啟用或停用玩家使用的表情浮在頭上的粒子。真的
sendContributingEmotes啟用或停用將小型表情符號傳送到巨型表情符號中的貢獻。真的
腳本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.configureServer({
emoteMinPlayers = 2,
playParticles = false,
})

配置客戶端

配置客戶端(config: table )

通過以下鑰匙/值在 config 表中覆蓋預設客戶端配置選項。此功能只能從 LocalScript 中呼叫。根據 guiType 值,注意到的標籤中的選項也適用。

關鍵說明預設
guiType控制形成 GUI 的控件將用於顯示表情 (EmoteBar.GuiType)。表情條
useTempo啟用或停用用戶能夠控制其表情是否過快或過慢的 節奏 功能,通過重複激活相同的表情來控制節奏。真的
tempoActivationWindow使用者在一個表情符號連續啟用期間的時間量,以秒為單位,用於計算為節奏的一部分。3
lockedImage圖像用於顯示頂部鎖定的表情符號。「rbxassetid://6905802778」
本地腳本 - 表情欄

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.configureClient({
guiType = EmoteBar.GuiType.EmoteBar,
maxEmotesPerPage = 6,
nextPageKey = Enum.KeyCode.Z,
prevPageKey = Enum.KeyCode.C,
})
本地腳本 - 表情輪

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.configureClient({
guiType = EmoteBar.GuiType.EmoteWheel,
})

設定表情符號

設定表情(表情: table )

設定要使用的自訂表情。如果 useDefaultEmotestrue,這些將被添加到默認值中;如果 useDefaultEmotesfalse,則會替換默認值。此功能只能從 Script 呼叫,並且變更將自動複製到所有客戶端。

查看 表情符號 以了解每個表情符號傳送到此函數的結構。

腳本 - 配置表情符號

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.configureServer({
useDefaultEmotes = false,
})
EmoteBar.setEmotes({
{
name = "Hello",
animation = "rbxassetid://3344650532",
image = "rbxassetid://7719817462",
defaultTempo = 1,
},
{
name = "Applaud",
animation = "rbxassetid://5915693819",
image = "rbxassetid://7720292217",
defaultTempo = 2,
},
})

設置GUI可見性

setGuiVisibility(可見: boolean )

顯示或隱藏表情GUI。此功能只能從特定客戶端的 LocalScript 呼叫。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.setGuiVisibility(false)

取得表情

獲取表情(表情名稱: string ):table

以名稱獲得 表情符號。如果找不到表情,返回 nil 。此功能只能從特定客戶端的 LocalScript 呼叫。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
local shrug = EmoteBar.getEmote("Shrug")

播放表情

playEmote(emote: 表情 )

播放指定的 表情,並在伺服器上發射 表情已發射 事件,如果連線。此功能只能從特定客戶端的 LocalScript 呼叫。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
local shrug = EmoteBar.getEmote("Shrug")
EmoteBar.playEmote(shrug)

鎖定表情

锁定表情(表情名称: string )

表情符號 鎖定在指定的名稱。此功能只能從客戶端的 LocalScript 呼叫。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.lockEmote("Applaud")

解鎖表情

解鎖表情(表情名稱: string )

使用指定名稱解鎖 表情。此功能只能從客戶端的 LocalScript 呼叫。

本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.unlockEmote("Applaud")

事件

表情已玩

當任何客戶播放動作時,發生火災。此事件只能在 LocalScript 中連接。

參數
玩家:Player行動出動作情的玩家。
動作:表情播放的表情。
本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.emotePlayed:Connect(function(player, emote)
print(player.Name, "played", emote.name)
end)

已鎖定的表情已啟用

當客戶單擊鎖定的動作時發生火災。此事件只能在 LocalScript 中連接。

參數
動作:表情已啟用的鎖定表情。
本地脚本

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local EmoteBar = require(ReplicatedStorage:WaitForChild("EmoteBar"))
EmoteBar.lockedEmoteActivated:Connect(function(emote)
print(Players.LocalPlayer, "clicked", emote.name)
end)