Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 2 months 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 paisley112 18 — 2mo

3 answers

Log in to vote
0
Answered by
ADUPS 5
2 months 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 566 Moderation Voter
2 months ago
Edited 2 months ago

Well you can do

local number = 0
repeat
    wait()
    number = number +1
until script.Parent.Alert.IsPlaying == false or number == 5
0
no incapaxx 2881 — 2mo
0
Wouldn't that just keep adding 1 to the number instead of only adding 1 each second? paisley112 18 — 2mo
0
oh yeah sorry, add a wait() inside the scope starmaq 566 — 2mo
Log in to vote
0
Answered by 2 months 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