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
This is my current script Frame 1 being the boundary and Frame 2 being the UI which we need to see if its in the bounds of Frame 1.
Anyways this is the result:

This is what I want:
![]()
This is how the message looks

This is the base message

Here’s the full script:
local CTE = {}
local Emojis = require(game.ReplicatedStorage["Pi-Chat"].Configurations).CustomEmojis
local GIFs = require(game.ReplicatedStorage["Pi-Chat"].Configurations).GIFs
local Index = 1
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,hl,DetectingFrame)
local Label = Instance.new("TextLabel")
Label.Parent = Parent
Label.Text = Text
Label.TextScaled = true
Label.RichText = true
Label.TextStrokeTransparency = MainLabel.TextStrokeTransparency
Label.Font = MainLabel.Font
Label.TextColor3 = Color == nil and MainLabel.TextColor3 or Color
Label.BackgroundTransparency = hl == true and 0.5 or 1
Label.BackgroundColor3 = Color3.fromRGB(47,87,147)
Label.Size = UDim2.fromScale(0,1)
Label.AutomaticSize = Enum.AutomaticSize.X
Label.Name = Index
if Checking then
game:GetService("Debris"):AddItem(Label,0)
return IsInBound(Label,DetectingFrame)
else
Index += 1
end
end
local function MakeImage(Id,MainLabel:TextLabel,Parent,Checking,DetectingFrame,isgif)
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
if Checking then
game:GetService("Debris"):AddItem(Label,0)
return IsInBound(Label,DetectingFrame)
else
if isgif then
local rayval = Instance.new("RayValue",Label)
rayval.Name = "IsGIF"
rayval.Parent = Label
end
Index += 1
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.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
function CTE.Solve(Label,Text,wordcolors,highlight)
Index = 1
Lines = 0
local strtable = Text:split(" ")
-- Bold
for i,v in pairs(strtable) do
if string.find(v,"%*%*") then
local v2 = "<b>"..v:gsub("**","").."</b>"
table.remove(strtable,i)
table.insert(strtable,i,v2)
end
end
-- Italic
for i,v in pairs(strtable) do
if v:find("//") then
local v2 = "<i>"..v:gsub("//","").."</i>"
table.remove(strtable,i)
table.insert(strtable,i,v2)
end
end
-- Underline
for i,v in pairs(strtable) do
if v:find("_") then
local v2 = "<u>"..v:gsub("_","").."</u>"
table.remove(strtable,i)
table.insert(strtable,i,v2)
end
end
-- Stike
for i,v in pairs(strtable) do
if v:find("~") then
local v2 = "<s>"..v:gsub("~","").."</s>"
table.remove(strtable,i)
table.insert(strtable,i,v2)
end
end
local frame = MakeLine(Label)
-- Start
for i,word in pairs(strtable) do
local color = wordcolors[i]
local hl = highlight[i]
local space = i==#strtable and "" or " "
local img = nil
local gif = false
for name,id in pairs(Emojis) do
if name == word then
img = id
gif = false
break
end
end
for name,id in pairs(GIFs) do
if name == word then
img = id.Id
gif = true
break
end
end
if img then
if MakeImage(img,Label,frame,true,Label,gif) then
MakeImage(img,Label,frame,false,nil,gif)
else
frame = MakeLine(Label)
MakeImage(img,Label,frame,false,nil,gif)
end
else
if MakeLabel(word..space,Label,frame,true,color,hl,Label) then
MakeLabel(word..space,Label,frame,false,color,hl,nil)
else
frame = MakeLine(Label)
MakeLabel(word..space,Label,frame,false,color,hl,nil)
end
end
end
end
return CTE