Tonumber() not working

Hi, i have a problem, when i try to convert a string to a number it doesn’t work, it gives me an error that says: “Players.shoutinpatataricaXD3.PlayerGui.tot.LocalScript:34: attempt to compare number <= string”

I tried to put a tostring and then a tonumber but nothing works…

Here’s the script

gui.Sel.Sell.MouseButton1Down:Connect(function()
			local thing = gui.Sel.TextBox.Text
			thing = tostring(thing)
			if tonumber(thing) ~= nil then
				for i,v in pairs(plr:WaitForChild("Invt"):GetChildren()) do
					if v.Value == "Wood" then
						local wu = tonumber(thing)
						print(wu)
						if v.Value >= wu then
							v.Value -= wu
							plr:WaitForChild("leaderstats").Money.Value += wu
						end
						return
					end
				end
				gui.Sel.TextBox.Text = "Not enough wood"
			else
				gui.Sel.TextBox.Text = "Invalid number"
			end

You check whether the value is “Wood”

Then try to compare it to a number. That’s the problem.

1 Like

OHHHHH I FORGOT THAT THING… i have another int value inside of that value, thank you sooooo much!!!