Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making an event happen during a period of time (ex. 11:05pm-11:10pm) instead of JUST at 11:05pm?

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

2 answers

✓ Accepted answer
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

3 comments

0

Basically what this does, it makes it happen around 06:05:00 and not exactly at 06:05:00

0

ah, that's interesting if that's really what that does. thank you for your answer, but for this specific event I am in need of something very precise where I can control exactly how long something lasts for.

0

hmmmm

This discussion is preserved as it was. New answers, comments, and votes are closed.