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

Is there a way to have a time limit on a repeat?

Asked by 5 years ago

Hiya, I'm trying to trigger a remote event if the player does not press "q" within 5 seconds. I currently have this and I was wondering how I could make it so that if "Alert" doesn't stop playing before 5 seconds then it triggers the remove event. Thanks

repeat
    wait()
until script.Parent.Alert.IsPlaying == false
0
After 5 seconds it should fire a remote server. I know how to do remote servers and all that its just I don't know how to get the repeat to know when 5 seconds has passed kieranhendy 28 — 5y

3 answers

Log in to vote
0
Answered by
ADUPS 5
5 years ago

I would suggest making a variable that counts each second, then when the player presses Q you detect if that variable is 5 or more. OR just add a timer for 5 seconds, and if it has passed 5 seconds, you just not allow the player to press Q. Can't really give you a proper answer because of lack of the information, sorry.

Ad
Log in to vote
0
Answered by
starmaq 1290 Moderation Voter
5 years ago
Edited 5 years ago

Well you can do

local number = 0
repeat
    wait()
    number = number +1
until script.Parent.Alert.IsPlaying == false or number == 5
0
no User#24403 69 — 5y
0
Wouldn't that just keep adding 1 to the number instead of only adding 1 each second? kieranhendy 28 — 5y
0
oh yeah sorry, add a wait() inside the scope starmaq 1290 — 5y
Log in to vote
0
Answered by 5 years ago

Thanks for the help but I've decided to work around this instead since the system I intended would be tricky for new players

Answer this question