In my custom chat UI, I have a frame for the area of the chat, and my system works in that it adds a text label featuring the player who typed it and the text (or if you want a better visualization, I'm working on a old Roblox recreation, and I'm using the 2006-2009 ish chat system).
What I want to do is detect if a text label has exited the bounds of the frame by any bit, and if so, destroy it. I'm doing this method because of, well, I'm not going to go into detail here, but basically screen sizes and stuff.
Here is my code if that helps.
script.Parent.FocusLost:Connect(function(enter)
local enteredText = script.Parent.Text
if enter then
script.Parent.Text = ""
game.ReplicatedStorage.Events.FilterChatMessages:FireServer(enteredText)
end
end)
game.ReplicatedStorage.Events.SendFilteredMessage.OnClientEvent:Connect(function(username, filteredText)
local text = Instance.new("TextLabel")
text.RichText = true
text.Font = Enum.Font.SourceSans
text.TextSize = 14
text.BorderSizePixel = 0
text.BackgroundColor3 = Color3.fromRGB(180, 180, 180)
text.TextColor3 = Color3.fromRGB(255, 255, 255)
text.BackgroundTransparency = 0.5
text.Text = '<b><i><font color="rgb(255,165,0)">'..username..'; </font> '..filteredText..'</i></b>'
text.Parent = script.Parent.Parent.ChatArea
wait()
text.Size = UDim2.new(0, text.TextBounds.X, 0, text.TextBounds.Y)
end)
Let me know if you need any more information.

3 comments
Why not set the frame's ClipDescendants property to true? It will hide any parts of the text label which are out of bounds.
ok, but how do i detect it when it does that so i can destroy it?
because i think it would lag if there are 3000 chat messages