Chat bubble background disappearing

I am using chat bubbles with custom background images to let guests take orders at the restaurant. Works fine, but whenever a new customer comes in, all the older chat bubbles lose their background image. They still have the right image in their script, I checked that.


2 Likes

Can you show the script? Are there any errors in the console?

local replicatedStorage = game:GetService("ReplicatedStorage")
local event = replicatedStorage.Seated
event.OnClientEvent:Connect(function(npc)
	local restaurant = game.Workspace:WaitForChild("Restaurant")
	local tables = restaurant:WaitForChild("Tables")
	local humanoid = npc:WaitForChild("Humanoid")
	local menu = restaurant.Menu:WaitForChild("Items"):GetChildren()
	local UIS = game:GetService("UserInputService")
	local chatService = game:GetService("Chat")
	chatService	.BubbleChatEnabled = true
	local newGuest = true
	local adornee = npc:FindFirstChild("HumanoidRootPart")
	if newGuest == true then
		local order = menu[math.random(1,#menu)]
		local cost = order.Cost.Value
		local image = order.Image.Value
		local bubbleChatSettings = {
			UserSpecificSettings = {
				[adornee:GetFullName()] = {
					Padding = 20,
					TailVisible = false,
					CornerEnabled = true,
					MaxBubbles = 2,
					BackgroundColor3 = Color3.fromRGB(250,250,250),
					BubbleDuration = 60,
					BackgroundImage = {
						Image = "rbxassetid://8061220414",
						ScaleType = Enum.ScaleType.Fit,
					}
				}
			}
		}
		chatService:SetBubbleChatSettings(bubbleChatSettings)
		chatService:Chat(adornee, " ")
		UIS.InputBegan:Connect(function(input, gameProcessed)
			if input.UserInputType == Enum.UserInputType.Keyboard then
				if input.KeyCode == Enum.KeyCode.E and newGuest == true then
					bubbleChatSettings = {
						UserSpecificSettings = {
							[adornee:GetFullName()] = {
								Padding = 20,
								TailVisible = false,
								CornerEnabled = true,
								MaxBubbles = 1,
								BackgroundColor3 = Color3.fromRGB(250,250,250),
								BubbleDuration = 120,
								BackgroundImage = {
									Image = image,
									ScaleType = Enum.ScaleType.Fit,
								}
							}
						}
					}
					chatService:SetBubbleChatSettings(bubbleChatSettings)
					chatService:Chat(adornee, " ")
					newGuest = false
				end
			end
		end)
	end
end)

There are no errors.

I’d recommend changing from the screenshot below Image = image, to Image = "rbxassetid://8061220414", like you did before.

afbeelding

this is a different image and it’s a variable because it’s chosen randomly. But it’s not the problem the second image shows up too, but only one bubble has a image at a time.
Looks like this after changing (the numbers are the cost):

Then I don’t really know, sorry. Someone else might be able to help you!

1 Like

I think what happens is when the LocalScript changes bubbleChatSettings the previous ones get deleted for every cloned npc, because the script is in ReplicatedStorage and works for every one of them. bubbleChatSettings is specified for only 1 npc so all the other ones are left with blank settings. Any ideas to prevent that?

EDIT: bubbleChatSettings as well as UserSpecificSettings are dictionaries, right? I’m trying to find a way to use table.insert or something like that to add new items to those dictionaries, instead of calling a new one every time.