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

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

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

1 comment

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

3 answers

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.

Well you can do

local number = 0
repeat
    wait()
    number = number +1
until script.Parent.Alert.IsPlaying == false or number == 5

3 comments

0

no

0

Wouldn't that just keep adding 1 to the number instead of only adding 1 each second?

0

oh yeah sorry, add a wait() inside the scope

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

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