表情是任何社交游戏的核心组成部分。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 | 变体,当玩家点击或轻触其角色时,表情在一个环中显示。 |
local 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 |
local 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" |
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,
})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调用,所做的更改将自动复制到所有客户端。
请参阅Emote以了解传递给此函数的每个表情的结构。
local 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调用。
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage.EmoteBar)
EmoteBar.setGuiVisibility(false)getEmote
通过名称获取Emote。如果找不到表情,则返回nil。此函数只能从特定客户端的LocalScript调用。
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage.EmoteBar)
local shrug = EmoteBar.getEmote("Shrug")playEmote
playEmote(emote: Emote)
播放给定的Emote,并在服务器上触发emotePlayed事件(如果已连接)。此函数只能从特定客户端的LocalScript调用。
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage.EmoteBar)
local shrug = EmoteBar.getEmote("Shrug")
EmoteBar.playEmote(shrug)lockEmote
lockEmote(emoteName: string)
锁定具有给定名称的Emote。此函数只能从客户端的LocalScript调用。
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage.EmoteBar)
EmoteBar.lockEmote("Applaud")unlockEmote
unlockEmote(emoteName: string)
解锁具有给定名称的Emote。此函数只能从客户端的LocalScript调用。
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmoteBar = require(ReplicatedStorage.EmoteBar)
EmoteBar.unlockEmote("Applaud")事件
emotePlayed
当任何客户端播放表情时触发。此事件只能在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: Emote | 被激活的锁定表情。 |
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)