How do I make a gui pop up depending on the time of the day

Whenever it turns a certain time like 18:00:00 in my game, Using The timeofday property, in lighting, is it possible to make a gui visible whenever it hits 18:00:00 in my day and night cycle

2 Likes

I think “os.time” will work, don’t really know much about these but you can take a look and it’ll maybe work.

1 Like

I believe OP is talking about game time rather than time in real life so you can use GetMinutesAfterMidnight. Here is the API:

1 Like

I inserted this script into the frame that I want to be visible when its a certain time

if game.Lighting.TimeOfDay == “13:20:00” then
script.Parent.Visible = true
end

this script is not working what’s the problem

  • a local script Btw

In the conditional try using this instead (it returns a double of the amount of minutes after midnight):

game.lighting:GetMinutesAfterMidnight()

Also make sure your day/night script doesn’t skip over the time you set. A good practice to be safe from this is instead of using if equal to, use “if greater than or equals” or “if less than or equals”

Try using this.

local Lighting = game:GetService("Lighting")
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if Lighting.ClockTime == 6 then
		-- do something
	end
end)

Also you should note that you are using the quotes wrong, it should be " and not “!

1 Like

To add onto the things over here, wouldn’t you have to make it a loop? Cause else it would only check the moment you start the game. You want it to check at all times.

Or am I completely wrong? I am not a scripter tbh.

Having :GetPropertyChangedSignal will check the value everytime it gets changed so loops are unneccessary in that case!

1 Like

[quote=“Desiccate, post:6, topic:850272”]

local Lighting = game:GetService("Lighting")
Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
	if Lighting.ClockTime == 6 then
		-- do something
	end
end)

local Lighting = game:GetService(“Lighting”)
Lighting:GetPropertyChangedSignal(“ClockTime”):Connect(function()
if Lighting.ClockTime == 6 then
– Thing I want to happen
script.Parent.Visible = true
– the gui does not turn visible
end
end)

is the script inside the frame you want to make visible? I have tested this prior posting and it works

Its A Local Script That Is Inside The Frame I want to turn Visible

is your day/night cycle using TimeOfDay instead of ClockTime? if so you would just have to change ClockTime with TimeOfDay and that should be it

1 Like