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

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

Make sure your Notification ScreenGui have the Enabled property set to false, and everything inside it have the visible property set to true.

You can also add a print in this part of code (bellow)

if Lighting.TimeOfDay == "12:00:00" then
    print("ShowingNotification")
	NotificationGui.Enabled = true
end

if the print work (which should), then the script work fine and the problem come from something in the other Gui

2 Likes

The text still didn’t pop up for some reason!
There is nothing else
image

EveryThing is fine for now I can just not put Notification and remove it!
Thank you for helping me!

1 Like

Thank you so much for helping me!

1 Like

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