How to detect when a TextLabel "exits" the frame?
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.
01 | script.Parent.FocusLost:Connect( function (enter) |
02 | local enteredText = script.Parent.Text |
05 | script.Parent.Text = "" |
07 | game.ReplicatedStorage.Events.FilterChatMessages:FireServer(enteredText) |
11 | game.ReplicatedStorage.Events.SendFilteredMessage.OnClientEvent:Connect( function (username, filteredText) |
13 | local text = Instance.new( "TextLabel" ) |
15 | text.Font = Enum.Font.SourceSans |
17 | text.BorderSizePixel = 0 |
18 | text.BackgroundColor 3 = Color 3. fromRGB( 180 , 180 , 180 ) |
19 | text.TextColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |
20 | text.BackgroundTransparency = 0.5 |
21 | text.Text = '<b><i><font color="rgb(255,165,0)">' ..username.. '; </font> ' ..filteredText.. '</i></b>' |
22 | text.Parent = script.Parent.Parent.ChatArea |
24 | text.Size = UDim 2. new( 0 , text.TextBounds.X, 0 , text.TextBounds.Y) |
Let me know if you need any more information.