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.
01 | local rtext = script.Parent.Parent.Random |
02 | local htext = script.Parent |
03 |
04 | htext.Text = 0 |
05 |
06 | while true do |
07 | wait(. 01 ) |
08 | if rtext.Text > htext.Text then |
09 | htext = rtext |
10 | end |
11 | 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
01 | local rtext = script.Parent.Parent.Random |
02 | local htext = script.Parent |
03 |
04 | htext.Text = tostring ( 0 ) |
05 |
06 | while true do |
07 | wait(. 01 ) |
08 | if tonumber (rtext.Text) > tonumber (htext.Text) then |
09 | htext = rtext |
10 | end |
11 | 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.
01 | local A = script.Parent.A |
02 | local B = script.Parent.B |
03 |
04 | B.Text = 0 |
05 | A.Text = 0 |
06 | while true do |
07 | wait(. 01 ) |
08 | if A.Text = = B.Text then |
09 | B = A |
10 | end |
11 | end |