表情是任何社交体验的核心组成部分。 EmoteBar 开发者模块旨在为玩家提供一种可访问的、可自定义的方式,以促进有意义的社交互动。
模块使用
安装
要在体验中使用 EmoteBar 模块:
从 Studio 的 窗口 菜单或 主页 选项卡工具栏中,打开 工具箱,并选择 创建者商店 选项卡。

确保选择了 模型 排序,然后点击 查看所有 按钮以查看 类别。

找到并点击 包 瓦片。
找到 Emote Bar 模块,点击它或将其拖放到 3D 视图中。

在 资源管理器 窗口中,将整个 EmoteBar 模型移动到 ReplicatedStorage。运行体验后,模块将开始运行。
配置
该模块预配置了 7 个表情,并且可以轻松使用您的自定义表情和显示选项进行自定义。此外,如果玩家拥有来自之前 Roblox 活动的任何表情,例如 Lil Nas X、Royal Blood 或 Twenty One Pilots,这些表情将自动添加到可用表情列表中。
在 ServerScriptService 中,创建一个新的 Script 并将其重命名为 ConfigureEmotes。

将以下代码粘贴到新的 ConfigureEmotes 脚本中。useDefaultEmotes 设置为 false 将覆盖默认表情,并允许您通过 setEmotes 函数定义自定义表情。
Script - ConfigureEmoteslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.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 | string | 表情名称,例如 "Shrug"。 |
| animation | string | 表情动画的资产 ID。 |
| image | string | 表情在 GUI 中的图像资产 ID。 |
| defaultTempo | number | 播放表情动画的默认速度因子。例如,节奏为 2 将以正常速度的两倍播放动画。必须大于 0。 |
| isLocked | bool | 表情是否“被锁定”无法被激活。 |
枚举
EmoteBar.GuiType
| 名称 | 摘要 |
|---|---|
| EmoteBar | 表情在屏幕底部的条形默认显示形式,分为单独的“页面”。 |
| EmoteWheel | 变体,当玩家点击或轻触其角色时,表情会以环形显示。 |
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)EmoteBar.configureClient({guiType = EmoteBar.GuiType.EmoteWheel,})
函数
configureServer
configureServer(config: table)
通过 config 表中的以下键/值覆盖默认服务器端配置选项。此函数只能从 Script 调用,更改将自动复制到所有客户端。
| 键 | 描述 | 默认 |
|---|---|---|
| useDefaultEmotes | 提供的默认表情是否包含在内。 | true |
| useMegaEmotes | 启用或禁用 大表情 功能。 | true |
| emoteMinPlayers | 执行相同表情所需的最小玩家数量,以贡献给大表情。 | 3 |
| emoteMaxPlayers | 执行相同表情所需的最大玩家数量,以贡献给大表情。 | 50 |
| playParticles | 启用或禁用玩家所执行的表情作为漂浮粒子在其头顶上。 | true |
| sendContributingEmotes | 启用或禁用发送小表情图标以贡献给大表情。 | true |
Scriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)EmoteBar.configureServer({emoteMinPlayers = 2,playParticles = false,})
configureClient
configureClient(config: table)
通过 config 表中的以下键/值覆盖默认客户端配置选项。此函数只能从 LocalScript 调用。根据 guiType 的值,注释中的选项也适用。
| 键 | 描述 | 默认 |
|---|---|---|
| guiType | 控制显示表情的 GUI 形式 (EmoteBar.GuiType)。 | EmoteBar |
| useTempo | 启用或禁用 节奏 功能,用户可以通过以节奏激活同一表情来控制表情播放的快慢。 | true |
| tempoActivationWindow | 用户在连续激活表情之间的时间,单位是秒,以使其计算为节奏的一部分。 | 3 |
| lockedImage | 要显示在锁定表情上方的图像。 | "rbxassetid://6905802778" |
LocalScript - 表情条local ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)EmoteBar.configureClient({guiType = EmoteBar.GuiType.EmoteBar,maxEmotesPerPage = 6,nextPageKey = Enum.KeyCode.Z,prevPageKey = Enum.KeyCode.C,})
LocalScript - 表情轮local ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)EmoteBar.configureClient({guiType = EmoteBar.GuiType.EmoteWheel,})
setEmotes
setEmotes(emotes: table)
设置要使用的自定义表情。如果 useDefaultEmotes 为 true,这些表情将添加到默认表情中;如果 useDefaultEmotes 为 false,则替换默认表情。此函数只能从 Script 调用,更改将自动复制到所有客户端。
请参见 表情 以了解传递给此函数的每个表情的结构。
Script - ConfigureEmoteslocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.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,},})
setGuiVisibility
setGuiVisibility(visible: boolean)
显示或隐藏表情 GUI。此函数只能从特定客户端的 LocalScript 调用。
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)EmoteBar.setGuiVisibility(false)
getEmote
通过名称获取 表情。如果找不到该表情则返回 nil。此函数只能从特定客户端的 LocalScript 调用。
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)local shrug = EmoteBar.getEmote("Shrug")
playEmote
playEmote(emote: Emote)
播放给定的 表情,并在服务器上触发 emotePlayed 事件(如果已连接)。此函数只能从特定客户端的 LocalScript 调用。
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)local shrug = EmoteBar.getEmote("Shrug")EmoteBar.playEmote(shrug)
lockEmote
lockEmote(emoteName: string)
锁定具有给定名称的 表情。此函数只能从客户端的 LocalScript 调用。
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)EmoteBar.lockEmote("Applaud")
unlockEmote
unlockEmote(emoteName: string)
解锁具有给定名称的 表情。此函数只能从客户端的 LocalScript 调用。
LocalScriptlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local EmoteBar = require(ReplicatedStorage.EmoteBar)EmoteBar.unlockEmote("Applaud")
事件
emotePlayed
当任何客户端播放表情时触发。此事件只能在 LocalScript 中连接。
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage.EmoteBar)
EmoteBar.emotePlayed:Connect(function(player, emote)
print(player.Name, "播放了", emote.name)
end)
lockedEmoteActivated
当客户端点击锁定表情时触发。此事件只能在 LocalScript 中连接。
| 参数 | |
|---|---|
| emote: 表情 | 被激活的锁定表情。 |
LocalScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local EmoteBar = require(ReplicatedStorage.EmoteBar)
EmoteBar.lockedEmoteActivated:Connect(function(emote)
print(Players.LocalPlayer, "点击了", emote.name)
end)