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.
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.
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.