How do I create these types of notifications?

I have the UI for it, I just don’t know how to script it.
Basically every like 30 seconds the UI will show up at the top of the screen. Each message is different.


Make a table containing al lthe messages you want to display and make a loop that every 30 seconds, display a message, you could make a check as well to determine if it’s the same message and if it is, generate again

1 Like

Create a table with the statements, and every 30 seconds, pick a random one to be shown.

Here’s an example I found in Scripting Helpers:
link: How do I get a random choice from a table? - Scripting Helpers


local table = {"Apple","Orange","String"} -- Items table.
local value = math.random(1,#table) -- Get random number with 1 to length of table.
local picked_value = table[value] -- Pick value from table
print(tostring(picked_value)) -- Print picked value

If you wanted to apply this for your game you should do something like this:

local UI = your ui
local ListOfMessages = {"Msg1", "Msg2"}
local value = math.random(1,#table)
local picked_val  = table[value]

UI.Text = (tostring(picked_value)) --this line is really bad, you would probably want to modify it a lot

Edit: you should have a wait too

Hello, There I see you need help!

This is my way ( beginners )

while true do -- If you dont want the textlabel to loop then remove the while true do
	NotiText:TweenPosition(, 0,0.036, 0),"In","Back")  -- Change This if you want
	NotiText:TweenPosition(, 0,1.02, 0),"In","Back")  
	NotiText:TweenPosition(, 0,0.036, 0),"In","Back") 
	NotiText.Text = "This game was scripted and built by NCSDeveloper1"
	NotiText.Text = "If your camera gets stuck in Mid-Air, make sure to reset! This bug will get resolve soon"
	NotiText:TweenPosition(, 0,1.02, 0),"In","Back")
	NotiText.Text = "Welcome to Test Your Time 2! "
	NotiText.Text = "Take your time, no neeed to rush! "
	NotiText.Text = "Halo shop might be coming to the game!?" 
	repeat until(100)

Something like this would display the messages in the correct order and repeat forever.

local textLabel = ...
local messages = {

while true do
    for i,v in ipairs(messages) do 
        textLabel.Text = v
1 Like

What exactly is this doing?
You’re doing an awful lot of unnecessary waits, but no waits between each text change, meaning the player won’t see some of the text.

wait() is based on the player’s FPS, which means a laggy player will have a horrible UI experience if waits aren’t depended on deltatime etc.

A working solution would be something like this:

local NotificationText = TextLabel --define here
local Notifications = {[1] = "Notification1"; [2] = "Notification2"; [3] = "Notification 4";} --and so forth, don't forget to include the key in order
--let's assume you're doing all UI management inside one local script, we would need to use a coroutine to loop without infinitely yielding the current thread
local loopFunction = coroutine.wrap(function() --wrap in coroutine
	local count = 1
	while wait(60) do --note: NEVER depend on the player's framerate to yield scripts, use deltatime
		NotificationText.Text = Notifications[count] --would print out "Notification1" on the first loop
		if not Notifications[count] then
			count = 1 --if we reached the end of the notifications available, go back to 1
			count += 1 --otherwise, carry on

loopFunction() --should run in a separate thread and not interrupt your script

@RipPBB_TUB You're ignoring the fact that RNG can also pick the same thing sometimes. The same notification may be picked in a row. To counter this issue my solution uses keys in a dictionary to keep count of which notification it is on.

Oh okay, I didn’t notice! thanks for alerting me. :grin:

1 Like

Yes, I was just giving a basic example, but you are correct, that could be a issue.

1 Like

Not sure why you would do it this way as @ducksandwifi said it is very unneeded/unorganized. (Not trying to hate if you think i’m hating)

1 Like

I’m honestly very confused. Everyone is giving me different scripts- :flushed:

Your good man! this is the easiest way for a beginner I’m guessing but there is a lot of way you can do it like using functions @ducksandwifi example