Text UI pop at (in-game) (12AM) script

Picture of the Clock GUI - image
Picture of the Script -

1 Like

is this in a localscript or a script

2 Likes

It is a local script
image

2 Likes

explorer:

image

localscript:

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())
2 Likes

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

1 Like
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
2 Likes

My clock text doesn’t work for some reason?
image

1 Like

i’m guessing that the problem is that the clock is just stuck at 00:00. are you updating PlayerGui or StarterGui?

1 Like

This is what I did and I put the script on the LocalScript!
image

2 Likes

Do I change any thing from here?

2 Likes

i’m working on it, hang on… character limit

2 Likes

Did you tried my code ???

1 Like

Sorry not yet let me try right now On what line do I put them on?
image

1 Like

sorry gtg character limit sorry

2 Likes

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

1 Like

Is it Like this? and It didn’t work!
I want the Text Ui to pop up at 9:55 PM

1 Like

Can you paste the script into a textbox (like the one bellow) so i can edit it?

type or paste code here
1 Like

I don’t have perm to type or paste on the box!

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
MidnightNotification.Enabled = true
task.wait(5)
MidnightNotification.Enabled = false
end
return string.format(“%02d:%02d %s”, hours, minutes, period)
end

print(getLightingTime())

1 Like

Let’s try that

local PlayerService = game:GetService("Players")
local Lighting = game:GetService("Lighting")

local Player = PlayerService.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local NotificationGui = PlayerGui and PlayerGui:WaitForChild("Notification")

local 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
	
	return string.format("%02d:%02d %s", Hours, Minutes, Period)
end

Lighting:GetPropertyChangedSignal("TimeOfDay"):Connect(function()
	script.Parent.Text = GetLightingTime()

	if Lighting.TimeOfDay == "12:00:00" then
		NotificationGui.Enabled = true
	end
end)
2 Likes

Why did my Notification GUI didn’t pop up? but the time clock works now!
thank you

1 Like