-
What do you want to achieve? I want to make it so if plrs on a certain team get a customs bubble chat color
-
What is the issue? when someone is chatting on said teams, the custom Bubble chat settings gets applied to everyone
Any help is appreciated as I really can’t figure out any others way to do that.
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local bubbleConfig = TextChatService:WaitForChild("BubbleChatConfiguration")
local function applyDefaultBubbleChatSettings()
bubbleConfig.BackgroundColor3 = Color3.fromRGB(250, 250, 250)
bubbleConfig.TextColor3 = Color3.fromRGB(57, 59, 61)
bubbleConfig.FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json")
end
local function updateBubbleChatForPlayer(player, message)
if player.Team then
if player.Team.Name == "Internal Security Department" then
bubbleConfig.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
bubbleConfig.TextColor3 = Color3.fromRGB(255, 255, 255)
bubbleConfig.FontFace = Font.new("rbxasset://fonts/families/RobotoMono.json")
elseif player.Team.Name == "Intelligence Agency" then
bubbleConfig.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
bubbleConfig.TextColor3 = Color3.fromRGB(255, 255, 255)
bubbleConfig.FontFace = Font.new("rbxasset://fonts/families/RobotoMono.json")
else
applyDefaultBubbleChatSettings()
end
else
applyDefaultBubbleChatSettings()
end
end
TextChatService.OnIncomingMessage = function(message)
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
if player then
updateBubbleChatForPlayer(player, message)
end
end
Players.PlayerAdded:Connect(function(player)
applyDefaultBubbleChatSettings()
end)
for _, player in ipairs(Players:GetPlayers()) do
applyDefaultBubbleChatSettings()
end
Im assuming this is ran on a server script, if you set something on textchatservice using a serverscript, it’ll apply to everyone. You need to apply it locally or reference one of those textchatservice functions that recieve individual messages and then you can check if that message pertains to a player who is in a specific team. And if it is, change that message color etc…
1 Like
Its ran on a local script in StarterPlayerScript
local Players = game:GetService("Players")
local TextChatService = game:GetService("TextChatService")
local Teams = game:GetService("Teams")
local bubbleConfig = TextChatService:WaitForChild("BubbleChatConfiguration")
local function applyDefaultBubbleChatSettings()
bubbleConfig.BackgroundColor3 = Color3.fromRGB(250, 250, 250)
bubbleConfig.TextColor3 = Color3.fromRGB(57, 59, 61)
bubbleConfig.FontFace = Font.new("rbxasset://fonts/families/GothamSSm.json")
end
local function updateBubbleChatForPlayer(player, message)
if player.Team then
if player.Team.Name == "Internal Security Department" then
bubbleConfig.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
bubbleConfig.TextColor3 = Color3.fromRGB(255, 255, 255)
bubbleConfig.FontFace = Font.new("rbxasset://fonts/families/RobotoMono.json")
elseif player.Team.Name == "Intelligence Agency" then
bubbleConfig.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
bubbleConfig.TextColor3 = Color3.fromRGB(255, 255, 255)
bubbleConfig.FontFace = Font.new("rbxasset://fonts/families/RobotoMono.json")
else
applyDefaultBubbleChatSettings()
end
else
applyDefaultBubbleChatSettings()
end
end
TextChatService.OnIncomingMessage = function(message)
local player = Players:GetPlayerByUserId(message.TextSource.UserId)
if player then
updateBubbleChatForPlayer(player, message)
end
end
for _, team : Team in Teams:GetChildren() do
team.PlayerAdded:Connect(function(player)
updateBubbleChatForPlayer(player)
end)
for _, teamMember in team:GetPlayers() do
updateBubbleChatForPlayer(teamMember)
end
end
maybe this will work?? idk cuz i didn’t test it
Players.UnnamedSkilI.PlayerScripts.Chat:32: attempt to index nil with ‘UserId’ - Client - Chat:32
02:14:05.288 Stack Begin - Studio
02:14:05.289 Script ‘Players.UnnamedSkilI.PlayerScripts.Chat’, Line 32 - Studio - Chat:32
02:14:05.289 Stack End - Studio
02:14:05.289 Error occurred while calling TextChatService.OnIncomingMessage: Players.UnnamedSkilI.PlayerScripts.Chat:32: attempt to index nil with ‘UserId’