Hello, I’m currently making a reaction time test minigame, however it is a bit different as they must click on the right word. The code works properly, however this section below is a bit inefficient. The repeat loop does not break once clicked, instead it waits the full 3 seconds until it goes to “Wrong Word!” Is there any way to make this break immediately? Thanks!
if not Correct then
repeat
green.TextButton.MouseButton1Down:Connect(function()
Wrong = true
end)
if wait(3) then
break
end
until Wrong == true
I am not sure why you are using a condition with a delay of 3 seconds before breaking your loop. If you want to break the loop if it has been more than 3 seconds, just let me know, and I’ll show you how.
You could check if 3 seconds have passed or if the button was press in the ‘until’ section like this:
if not Correct then
local t = tick()
repeat
green.TextButton.MouseButton1Down:Connect(function()
Wrong = true
end)
task.wait()
until Wrong == true or tick() - t >= 3
This works for when the player clicks, but I want it to disappear after 3 seconds so it resets. Basically, the player needs to recognize that it’s the wrong word, and when they do, it keeps cycling through.
For some reason, now it takes a long while to show a word, and the only word that shows in the correct one? I think one issue is I’ve already used tick in a line before.
Here’s what I think went wrong:
if ready then
green.TextLabel.Text = randomWord
t = tick()
green.Visible = true
red.Visible = false
if randomWord == "Click!" then
Correct = true
end
if not Correct then
local startTick = tick()
--your code
There is no link between the two variables using tick. You named them with different names, they don’t interact with each other. I’m not entirely sure about the exact problem in this script. Can you provide more details about the issue? Perhaps use a little gif or video to demonstrate how it behaves during testing and explain what it’s supposed to look like?