I am new to a script (coding) and I wanted to make a text gui that sends a text message in (in-game) time at exact (12AM)! I need help asap on this script!
Here is a example that I’m talking about when the (in-game) time hits 9:55 the text will pop up by saying “Show will start in 5 Minutes”!
Here is a picture of the idea that I’m talking about!
local player = game:GetService("Players").LocalPlayer
local notifgui = player.PlayerGui:WaitForChild("Notification")
function getLightingTime()
local totalMinutes = game.Lighting:GetMinutesAfterMidnight()
local hours = math.floor(totalMinutes / 60)
local minutes = math.floor(totalMinutes % 60)
local period
if hours < 12 then
period = "AM"
else
period = "PM"
hours -= 12
end
if hours == 0 then
hours = 12
end
if hours == 12 and period == "AM" then
--Midnight
notifgui.Enabled = true
task.wait(5)
notifgui.Enabled = false
end
return string.format("%02d:%02d %s", hours, minutes, period)
end
print(getLightingTime())
MidnightNotification is just a textlabel that says “it’s midnight” or something, and the Enabled property on ScreenGuis determines whether or not it’s visible
game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
Gui.Text = getLightingTime()
if game.Lighting.ClockTime == 12 then
--Code to put the frame visible
YourGuiFrame.Visible = true
end
--You can also use this for more precision
--Choose only one of both (ClockTime or TimeOfDay) and delete the other
if game.Lighting.TimeOfDay == "12:00:00" then
YourGuiFrame.Visible = true
end
end
It is instead of the while true do, and make sure to change the YourGuiFrame thing to your actual frame you want to show off when the wanted time is reached