If statement does not fire

local status1 = game.ReplicatedStorage:WaitForChild("Status1")
script.Parent.Text = status1.Value

status1.Changed:Connect(function()
	script.Parent.Text = status1.Value
end)

status1.Value = 9

script.Parent.MouseButton1Click:Connect(function()
	print ("Something new")
	if status1.Value == 9 then
		status1.Value = 0
	else
		status1.Value = status1.Value + 1 
	end 
end)

This is everything in the script I just cannot figure out why the else is firing even when status.Value is 9

Is Status1 a StringValue? If so, try checking if status1.Value == “9” instead of 9

2 Likes

How would I check this, should I change it to an int value

Try changing it to an IntValue.
Could you send the place file?

No, thanks I am not giving the place file. It is kinda a big game and I don’t want to risk it getting stolen.

Yes, I would but you don’t have to. It should be a number value if you ever think you will work with decimals.

If you want to keep it as a string, then do this:

local status1 = game.ReplicatedStorage:WaitForChild("Status1")
script.Parent.Text = status1.Value

status1.Changed:Connect(function()
	script.Parent.Text = status1.Value
end)

status1.Value = 9

script.Parent.MouseButton1Click:Connect(function()
	print ("Something new")
	if tonumber(status1.Value) == 9 then
		status1.Value = 9
	else
		status1.Value = tonumber(status1.Value) + 1 
	end 
end)

That may work, but it’s better to change it to NumberValue or a IntValue for easier use. Check the ClassName to see if the value is a StringValue in the properties tab.

You only need to send the elements in use. Your code looks fine so it’s likely the value in ReplicatedStorage that’s causing the logic error.

1 Like

Or you could screenshot things.

1 Like

Here is a screenshot of the UI thing. What I want is that everytime someone click the text button the number goes up until it hits nine the it will turn to 0 again.

This works thanks so much for the help :slight_smile: