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

I want a timer to start when a TextBox has changed, but won't work. Why?

I have a TextBox and I want it to time the amount of time it takes to type in a certain piece of text, however, whenever I have used the 'Changed' function it just starts multiple timers every time the TextBox has changed. This is what I have come up with so far but can't figure out the rest. (Local script)

Code:

local timer = 0

script.Parent.enterText.Changed:Connect(function()
	while timer < 60 do
		if timer > 1 then
			print("Timer started")
			wait(1)
			timer = timer + 1
		else
			timer = timer + 1
		end
	end
end)

1 answer

✓ Accepted answer

You can do this using the Focused event.

-- Simplified version
local timer = 0

script.Parent.enterText.Focused:Connect(function()
	for i = 0, 60 do
		timer = i + 1
		wait(1)
	end
end)

1 comment

0

Works, thanks.

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