Picture of the Clock GUI -
Picture of the Script -
is this in a localscript or a script
It is a local script
explorer:
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())
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
My clock text doesn’t work for some reason?
i’m guessing that the problem is that the clock is just stuck at 00:00. are you updating PlayerGui or StarterGui?
This is what I did and I put the script on the LocalScript!
i’m working on it, hang on… character limit
Did you tried my code ???
Sorry not yet let me try right now On what line do I put them on?
sorry gtg character limit sorry
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
Can you paste the script into a textbox (like the one bellow) so i can edit it?
type or paste code here
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())
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)
Why did my Notification GUI didn’t pop up? but the time clock works now!
thank you