Making Text in scrollbox dissappear after 10 seconds

Hi,

I’ve made a basic chat that takes input from a message and displays it in a scrollbox. The thing is, I want all the messages in the box to be deleted after 10 seconds, I don’t actually want the user to be able to go back and read messages, and if there is no recent messages I don’t want people to have text on their screen.

What’s the best way to do this?

Run a looping 10s timer and remove scroll box child 0. Check if the scrollbox is empty first.

2 Likes

Thank you, this was very helpful. One further question though if you don’t mind: Is there a way to do it to it based on when the message was created?

Example: 3 messages come in quick succession, as your code works it would be 30 seconds before the last of them is deleted, however I want their total lifetime to be 10 seconds each, so they all disappear together.

BP if needed

In that case it would be easier to script the disappearing act into the message itself. Each message should be a user widget (they already are, right?) So it can:

No other script would be necessary.


Another alternative would be to run a timer with a varying interval - the more messages there are, the more rapidly it removes them. But the earlier suggestion seems more inline with the ask.

1 Like

Ah beautiful, after how hard it was to get the text to match the player material colour I didn’t expect it to be this easy. But thank you. Works perfect.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.