So I want a system that adds a image in between text so for example
A better example can be seen in Breaking Point. Type :cat: in that game and see the results.
Input: “I just got :oof:”
Output: "I just got "
And no I am not gonna use the existing Rich text module cuz it makes soo many text labels it might cause lag.
UI elements don’t generate much lag at all. Things that generate lag are things that require computation. Displaying a constant text thing is doing no computation, so it will cause no lag.
custom-made chat and so I got the image but only once now. what i need ur help in is to tell me how to get the number of replacements made by string.gsub… cuz IDK how to do that.
local label = script.Parent.TextLabel
local images = {
[1] = {
id = 579178678,
name = ":ye:"
}
}
local str = ":ye:DOES IT WORK?:ye:"
local finalstr,times = string.gsub(str,images[1].name,"")
local split = string.split(str,images[1].name)
local frame = Instance.new("Frame",label)
frame.AutomaticSize = Enum.AutomaticSize.XY
frame.BackgroundTransparency = 1
frame.Size = UDim2.new(0,0,0,0)
local uilistlayout = Instance.new("UIListLayout",frame)
uilistlayout.FillDirection = Enum.FillDirection.Horizontal
uilistlayout.SortOrder = Enum.SortOrder.Name
local num = 0
for i,v in pairs(split) do
local line = Instance.new("TextLabel",frame)
line.Name = num
num += 1
line.TextSize = label.TextSize
line.TextColor3 = label.TextColor3
line.BackgroundTransparency = 1
line.AutomaticSize = Enum.AutomaticSize.XY
line.Text = v
end
for i=1,times do
local img = Instance.new("ImageLabel")
img.Name = num
num += 1
img.Size = UDim2.fromOffset(label.TextSize,label.TextSize)
img.Image = "rbxassetid://"..images[1].id
img.BackgroundTransparency = 1
img.Parent = frame
end