Jump to content

[Help] Call a function when a certain time comes


Recommended Posts

So, I'm creating an alarm system, and I need help since I'm fairly new to this. So I've already got most stuff down, except the main part, calling the alarm sound when the set time comes. Could someone just give me a few tips on how I would go about this? And please, don't just give me a script that will work, cause I won't learn that way :D

Link to comment

Well, the player sets an alarm in 24 hour time. I want it so when local time (aka getRealTime) reaches that time, it plays a sound. Right now I have it so if the time set = current time, it plays the sound. Just as a test though, and it works flawlessly.

Link to comment

How about you do something like this:

When the player sets the alarm, it does: local time = alarmTime - currentTime

and then you use setTimer(yourFunction, time, 1)

This would work if the alarm is set further the currentTime AND in the same day.

You can just find out how to make it work for alarms set to the next day.

Link to comment
How about you do something like this:

When the player sets the alarm, it does: local time = alarmTime - currentTime

and then you use setTimer(yourFunction, time, 1)

This would work if the alarm is set further the currentTime AND in the same day.

You can just find out how to make it work for alarms set to the next day.

I thought about it, but wouldn't that result in the alarm being slightly off? Possibly even by 50 seconds?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...