The IF statement in my LocalScript isnt working

I have made a localscript in a textbutton (in startergui) which is meant to print something if an intvalue and the text are the same.

Both the text and the intvalue are 100 (and it will print 100 for both) but the IF statement doesn’t think 100 and 100 are equal.

I assume I’m doing this wrong, how should I fix this?

-- local button = script.Parent
local text = script.Parent.label
local player = game.Players.LocalPlayer
local price = script.Parent.Parent.Price

button.Activated:Connect(function()
	print(price.Value.." is the price") -- Prints 100 is the price
	print(text.Text.." is the text") -- Prints 100 is the text
	if price.Value == text.Text then
		print(price.Value.." and "..text.Text.." ARE the same.") -- doesn't print
	else
		print(price.Value.." and "..text.Text.." are NOT the same.") -- Prints 100 and 100 are NOT the same
	end
end)

Make sure your comparing two numbers, not a number and a string

You can convert your string to a number using tonumber(text.Text)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.