How to add images in messages ? (Like KAT)

How do I add images in chat

I don’t know how I have tried a lot of solutions. My example is like
“Hello bruh”
Becomes
"Hello "

I have tried many solutions but I can’t find anything! I wanted to make this as I think it’s cool that KAT did this. I have tried many devforum posts on making them but there is non for chat, there is only ones with TextLabels and Frames which I can’t add into the chat

If anyone knows please tell me here!

You would have to make a custom chat and change certain words to images.

2 Likes

How would I go with inserting the image into the message though? Like if they say “hello bruh, I am bruh”
it would add the image ONLY where “bruh” is

it’s sort of like commands. You would do it like this:

local image = --image for bruh

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        local words = msg:split(" ")
        
        for i,v in pairs(words) do
            if v == "bruh" then
                table.remove(words, i)
                table.insert(words, image, i)
            end
        end

        local str = ""

        for i,v in pairs(words) do
            str ..= v..(i < #words and " " or "")
        end
        
        --send word to everyone
    end)
end)
2 Likes

So it shows the landing it is on for example
“Hello I am bruh”
becomes
“Hello I am4”
and “bruh”
becomes “1”
but how would I make it insert an imagelabel there so the image can show?
OR
Anyway to show the image.

If the image were to be a copy-pasteable emoji, you could put it into the text. I believe anyone who puts images into chat does it with emojis.

No I mean like everytime you add a CERTAIN SPECIAL keyword then it adds a imagelabel or whatever to make the image because in KAT for example if you say “bruh” it shows an image whereever you said bruh, I don’t want normal emojis.

I literally have done that! Essentially what you are gonna do is

local input = "Hello :bruh:"
local ss = "★" -- this is used a separator so that it wont remove smiles ":)"
local emojis = {
[":bruh:"] = 12392131 -- id (this one is NOT valid)
}
for i,v in pairs(emojis) do
if string.find(input,i) then
input = input:gsub(i,ss..string.gsub(i,":","")..ss
end
end

-- input would in theory be Hello ★bruh★ now lets split it!

local split = string.split(input,ss)

for i,v in pairs(split) do
local isimg = false
 for i,v in pairs(emojis) do
  if v == i then
   isimg = true
  end
 end

if isimg then
-- add imagelabel
else
-- add textlabel
end
end

this is NOT tested and I am not gonna give my custom emoji script. Cuz its copy righted.

Also one thing add a frame in that text label. with a ui list layout that has sortorder = name
and then just name the images and text labels to numbers from start to finish.

2 Likes

I understand this but I am confused on how to add it so if I say “I am bruh how’re you bruh?”
It will show the message as
“I am [image here] how’re you [image here]?”
I don’t know how to get the offset and stuff to make it setup like that…

And sad your one is copyrighted

OH okay well that edit is reassuring. I will try that right now, if It doesn’t work I will just ping ya for more help !

you making this a bit more tough. I guess ill give you my script edited ofc.
cuz it took me a LONG time to make it and am not gonna give it full.

also remember this only works for horizontal textlabel so it would only work for 1 line.
its up to you to edit it NOT MINE. and it does NOT respect screen sizes
as it uses offset

local CustomEmoji = {}

local label
local images = {["bruh"] = 12312312312312}

local num = 0

local function addlabel(text,frame)
	if text ~= "" then
		local line = Instance.new("TextLabel",frame)
		line.Name = num
		num += 1
		line.Size = UDim2.fromOffset(0,label.TextSize)
		line.Font = require(game.ReplicatedStorage:WaitForChild("PieChat").Config).Font
		line.TextSize = label.TextSize
		line.TextColor3 = label.TextColor3
		line.BackgroundTransparency = 1
		line.AutomaticSize = Enum.AutomaticSize.X
		line.Text = text
		line.RichText = true
		line.TextScaled = true
	end
end

local function addimg(id,frame,isgif,tab)
	local img = Instance.new("ImageLabel")
	img.Name = num
	num += 1
	img.Size = UDim2.fromOffset(label.TextSize,label.TextSize)
	img.Image = "rbxassetid://"..id
	img.BackgroundTransparency = 1
	img.Parent = frame
end

local function update(str)
	if label:FindFirstChild("Line") then label.Line:Destroy() end
	num = 0
	for i,v in pairs(images) do
		str = str:gsub(i,"★"..i:gsub(":","").."★")
	end
	local split = string.split(str,"★")

	local frame = Instance.new("Frame",label)
	frame.Name = "Line"
	frame.AutomaticSize = Enum.AutomaticSize.Y
	frame.BackgroundTransparency = 1
	frame.Size = UDim2.fromOffset(label.TextBounds.X,label.TextBounds.Y)
	local uilistlayout = Instance.new("UIListLayout",frame)
	uilistlayout.FillDirection = Enum.FillDirection.Horizontal
	uilistlayout.SortOrder = Enum.SortOrder.Name

	for i,v in pairs(split) do
		local imgg = nil
		for ii,img in pairs(images) do
			if v:lower() == string.gsub(ii,":","") then
					imgg = img
				break
			end
		end
		if imgg then
			addimg(imgg,frame)
		else
			addlabel(v,frame)
		end
	end
end

function CustomEmoji.Update(Label,Text)
	label = Label
	update(Text)
end

return CustomEmoji

-- Give me credits.
1 Like

the full script is copyrighted as its very advance and uses GIFS. this is acctually for a chat system I am making called Pie Chat and when it releases all my scripts will be un copy righted. (If I release it to public ofc) you can sort of test it. its still in beta. doe

What do I write for the credits :skull_and_crossbones:

Just say custom emoji made by me (kidsteve923) cuz i like credits :). Also you may think HOW TO USE IT?

I gotchu my guy

local CE = require() -- path to custom emoji module (CE = Custom Emojis)
local Label = script.Parent
local Text = "Whats up :bruh:"
CE.Update(Label,Text)

Thanks to that too man ! I was somewhat confused lol

OH BOY ITS WORKS!
AND Thanks to yo-
wait a minute…
image
suffering, :Waa:

Yea np people get confused with my messy scripts. And hopefully after seeing this NO ONE message me and say “work for me pwease”

1 Like

can you show me the full umm what do you call it output

image
the full output minus the other scripts I used to this testing game :waa:
The code (just checking if they send msg bc yes)

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(c)
		local lab = Instance.new('TextLabel')
		lab.Parent = --their plrgui gui thingy eefhdjvmnhgdhf
		require(game.ReplicatedStorage.EMOJI):Update(lab,'Whatsup :bruh:')
	end)
end)

delete that line. its useless.

1 Like