Detecting When Text Label Counter hits a Certain Number

Hey there!
How would I modify this script to detect when the text is displaying 100 or higher? I’m trying to use this to start a fire on the part when it reaches that number, but it doesn’t do anything.

Script:

local Text = script.Parent
local fire = Text.Parent.Parent.Fire

Text.Text = 0

while true do
	if workspace.Button.Value.Value == true then
		Text.Text = Text.Text + 1
		wait(0.4)
	else
		Text.Text = Text.Text + 1
		wait(0.1)
	end
end

I tried if statements, but none of it worked.

The only way I can think of it is

if Text.Text == 69 then
-- do this
end

I tried that, but it didn’t work, either.

The text should be a string, you cannot add a string. You need to convert it to a number.

How do I do that?
3Ocharacterss

I think you can use tonumber. Also if that is not the problem, can I ask if this is in a script or localscript?

The script is a normal script. I can send you a screenshot of it in explorer and studio, if you want?

I don’t think you can check the text from the server, you need to use remote events to send an arg from the client to the server. Edit: Also a screenshot would actually help.

Ah yes my bad, there should be "s around the number, like this

if Text.Text == "69" then
-- do this
end
1 Like

If @gxenious’s way does not work, try using remote events & use his method.

I think you need to use remote events and @gxenious’s fixed version. But just try his fixed version first:

Edit: I was wrong and you can add strings, so I think it should work.

This one worked just fine, actually. Thanks.

1 Like

This is a bit offtopic, but instead of using while true do you could do

game.workspace.Button.Value.Changed:Connect(function()
local Text = script.Parent
local fire = Text.Parent.Parent.Fire
Text.Text = 0

if workspace.Button.Value.Value == true then
	Text.Text = Text.Text + 1
	wait(0.4)
else
	Text.Text = Text.Text + 1
	wait(0.1)
end
end)