I am just messing around with random numbers and was trying to make a system that would update every time a higher number is generated.
local rtext = script.Parent.Parent.Random local htext = script.Parent htext.Text = 0 while true do wait(.01) if rtext.Text > htext.Text then htext = rtext end end
When I run this the console says I am trying to compare nil values, is there an easy way to make the text from a GUI into an integer value?
Tonumber() can solve your issue
local rtext = script.Parent.Parent.Random local htext = script.Parent htext.Text = tostring(0) while true do wait(.01) if tonumber(rtext.Text) > tonumber(htext.Text) then htext = rtext end end
It converts any given value to a number if possible.
Its because rtext doesnt have text, also because you used =, instead of == to compare values. Here is the script btw: I also used A and B instead of rtext and htext, so change it however you'd like.
local A = script.Parent.A local B = script.Parent.B B.Text = 0 A.Text = 0 while true do wait(.01) if A.Text == B.Text then B = A end end