So I am making a custom text engine that is like discord aka custom emojis/gifs and rn I want to add rich text aka colors bold italics underlines strikethrough and I am having issue with them.
local Text = "(c=255,0,0)Hey! Hey!(c) Bro!"
local Index = 1
local Emojis = {
[":bruh:"] = 7770278986
}
local function IsInBound(Frame2, Frame1)
if Frame2.AbsolutePosition.X < Frame1.AbsolutePosition.X or Frame2.AbsolutePosition.Y < Frame1.AbsolutePosition.Y then
return false
end
if Frame2.AbsolutePosition.X+Frame2.AbsoluteSize.X > Frame1.AbsolutePosition.X+Frame1.AbsoluteSize.X then
return false
end
if Frame2.AbsolutePosition.Y+Frame2.AbsoluteSize.Y > Frame1.AbsolutePosition.Y+Frame1.AbsoluteSize.Y then
return false
end
return true
end
local function MakeLabel(Text,MainLabel:TextLabel,Parent,Checking,Color)
local Label = Instance.new("TextLabel")
Label.Parent = Parent
Label.Text = Text
Label.TextScaled = true
Label.Font = MainLabel.Font
Label.TextColor3 = Color == nil and MainLabel.TextColor3 or Color
Label.BackgroundTransparency = 1
Label.Size = UDim2.fromScale(0,1)
Label.AutomaticSize = Enum.AutomaticSize.X
Label.Name = Index
Index += 1
if Checking then
game:GetService("Debris"):AddItem(Label,0)
return IsInBound(Label,MainLabel)
end
end
local function MakeImage(Id,MainLabel:TextLabel,Parent,Checking)
local Label = Instance.new("ImageLabel")
Label.Parent = Parent
Label.Image = "rbxassetid://"..Id
Label.BackgroundTransparency = 1
Label.Size = UDim2.fromScale(1,1)
local UIAspectRatioConstraint = Instance.new("UIAspectRatioConstraint")
UIAspectRatioConstraint.Parent = Label
UIAspectRatioConstraint.AspectRatio = 1
Label.Name = Index
Index += 1
if Checking then
game:GetService("Debris"):AddItem(Label,0)
return IsInBound(Label,MainLabel)
end
end
local Lines = 0
local function MakeLine(Parent:TextLabel)
Index = 1
local Frame = Instance.new("Frame")
Frame.Parent = Parent
Frame.Size = UDim2.new(1,0,0,Parent.TextSize)
Frame.Position = UDim2.new(0,0,0,Parent.TextSize*Lines)
Frame.Transparency = 1
Lines += 1
local UIListLayout = Instance.new("UIListLayout")
UIListLayout.Parent = Frame
UIListLayout.FillDirection = Enum.FillDirection.Horizontal
UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
Frame.Name = "Line "..Lines
return Frame
end
local frame = MakeLine(script.Parent)
local strtable = Text:split(" ")
for i,notfixedword in pairs(strtable) do
local space = i==strtable and "" or " "
local word = notfixedword
local img = nil
local color = nil
for name,id in pairs(Emojis) do
if name == word then
img = id
break
end
end
if img then
if MakeImage(img,script.Parent,frame,true) then
MakeImage(img,script.Parent,frame,false)
else
frame = MakeLine(script.Parent)
MakeImage(img,script.Parent,frame,false)
end
else
if MakeLabel(word..space,script.Parent,frame,true,color) then
MakeLabel(word..space,script.Parent,frame,false,color)
else
frame = MakeLine(script.Parent)
MakeLabel(word..space,script.Parent,frame,false,color)
end
end
wait()
end
This is my script you can test it yourself just make a textlabel and put a localscript inside of it and just paste that in there. now can any of you tell me how can I achieve such a thing? You can see that at the top I said (c=255,0,0)Hey! Hey!(c) Bro!
I want the Hey! Hey! to appear in red and Bro! yea I have taken care of that. Can someone please help me in it?
Thanks for seeing this.