Hi there! My script tells a GUI to "pop up" at a certain time, (ex. 11:05pm, grabbing the time from the lighting) but there's a problem - new people who come in the server at 11:06pm will not get this message because they weren't in the server when this script told something to happen in a Player's GUI at 11:05pm.
So, the question is, how would I make something happen during say, 11:05pm-11:20pm instead of only 11:05pm that has to do with the player, that technically doesn't even exist yet so it would need to keep looping this every 1 second throughout the times of 11:05pm to 11:15pm? Or if you could refer me to the wiki where you found this type of information stored? I am not able to find it :c
Thanks!
player = game.Players.LocalPlayer while true do if game.Lighting.TimeOfDay == "06:05:00" then --Notifications 7:20AM player.PlayerGui.PopUp.Frame.slidein.Disabled = false player.PlayerGui.PopUp.Frame.text.Text = ("HI HELLO") wait(10) player.PlayerGui.PopUp.Frame.slidein.Disabled = true player.PlayerGui.PopUp.Frame.slideout.Disabled = false end wait(1) end
player = game.Players.LocalPlayer local debounce = true while true do if game.Lighting.ClockTime >= (6 + 5/60) and game.Lighting.ClockTime <= (6+ 15/60) and debounce then debounce = false player.PlayerGui.PopUp.Frame.slidein.Disabled = false player.PlayerGui.PopUp.Frame.text.Text = ("HI HELLO") wait(10) player.PlayerGui.PopUp.Frame.slidein.Disabled = true player.PlayerGui.PopUp.Frame.slideout.Disabled = false else if game.Lighting.ClockTime > (6 + 20/60) then debounce = true end wait(1) end
That should work better. I use ClockTime because it's better to use with ranges of time.
6 + 5/60 corresponds to the number of hours elapsed at 6:05 (60 minutes in an hour is how I got that piece of the fraction). I also set a debounce so that it doesn't constantly slide in and out. The code is not as pretty as I would like it (would furiously upvote any answer with events or some scheduler service).
Try using ~= then it would be
player = game.Players.LocalPlayer while true do if game.Lighting.TimeOfDay ~= "06:05:00" then --Notifications 7:20AM player.PlayerGui.PopUp.Frame.slidein.Disabled = false player.PlayerGui.PopUp.Frame.text.Text = ("HI HELLO") wait(10) player.PlayerGui.PopUp.Frame.slidein.Disabled = true player.PlayerGui.PopUp.Frame.slideout.Disabled = false end wait(1) end