Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago
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).

Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

0
Basically what this does, it makes it happen around 06:05:00 and not exactly at 06:05:00 DanielDeJong -13 — 6y
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. callmehbob 54 — 6y
0
hmmmm DanielDeJong -13 — 6y

Answer this question