Gui not popping up again?

Hello! I made a script where it detects if it’s night, it’ll trigger a remote event which makes the gui visible. it works the first time, but on the 2nd night, it dosen’t pop up. Any help is appreciated!

local RepStorage = game:GetService("ReplicatedStorage")
local NightEvent = RepStorage:WaitForChild("NightEvent")
local prompt = game.Workspace.Sled2.SledPrompt.ProximityPrompt
local ClearEvent = RepStorage:WaitForChild("ClearEvent")

game.Lighting.ClockTime = 14

while true do
	game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
	minutesAfterMidnight = minutesAfterMidnight + .2 -- .2
	wait(.1)
	
	if game.Lighting:GetMinutesAfterMidnight() == 6 * 60 then		-- checks for 6AM
		if prompt.Enabled == true then
			prompt.Enabled = false
		end
	end
	
	if game.Lighting:GetMinutesAfterMidnight() == 18.38 * 60 then		-- checks for 6PM
		NightEvent:FireAllClients(minutesAfterMidnight)
		ClearEvent:FireAllClients(true)
		if prompt.Enabled == false then
			prompt.Enabled = true
		end
		end
end

It would be useful to see the LocalScript handling the remote events, furthermore, have you tried print debugging your scripts and checked which script is the cause of the issue? Might be down to one particular statement or the handling of events.

Well, a local script does handle the remote events, I’ll try using print commands.

I’d also recommend adding prints for the variables sent from the server on the LocalScript, this ensures that you can check for differences on the variables from the 1st and 2nd nights.

Heres the Night event local script:

local gui = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local NightEvent = ReplicatedStorage:WaitForChild("NightEvent")

NightEvent.OnClientEvent:Connect(function()
	gui.Visible = true
end)

I’m presuming ‘gui’ is already defined under a variable. My suggestion would be to print the variable “minutesAfterMidnight” in the second if statement and compare the values of it on both nights.

I formatted the code incorrectly, hold on.