I have a lil script that you gotta guess a random number and it keeps saying attempt to compare number > string and idk why
local number = math.random(1,10)
local view = script.Parent.HighOrLow
local box = script.Parent.TextBox
print(number)
while true do
wait (0.05)
if box.Text == number then
view = (":)")
elseif box.Text > number then
view.Text = ("Lower")
elseif box.Text < number then
view.Text = ("Higher")
end
end
So how do I turn the string to a value btw view is a text label
local number = math.random(1,10)
local view = script.Parent.HighOrLow
local box = script.Parent.TextBox
print(number)
while true do
wait(0.05)
if tonumber(box.Text) == number then
view.Text = (":)")
elseif tonumber(box.Text) > number then
view.Text = ("Lower")
if tonumber(box.Text) < number then
view.Text = ("Higher")
end
end
end
local number = math.random(1,10)
local view = script.Parent.HighOrLow
local box = script.Parent.TextBox
print(number)
while true do
wait(0.05)
if tonumber(box.Text) == number then
view.Text = (":)")
if tonumber(box.Text) == nil then
continue
end
elseif tonumber(box.Text) > number then
view.Text = ("Lower")
if tonumber(box.Text) < number then
view.Text = ("Higher")
end
end
end
end
this should prevent that type of error from happening again
unless I’m wrong and continue isn’t allowed in while loops, idk since I haven’t tested it but you could tell me if it works
It didn’t work but I tweaked ur script and got dis
local number = math.random(1,10)
local view = script.Parent.HighOrLow
local box = script.Parent.TextBox
print(number)
while true do
wait(0.05)
if tonumber(box.Text) ~= nil then
if tonumber(box.Text) == number then
view.Text = (":)")
elseif tonumber(box.Text) > number then
view.Text = ("Lower")
elseif tonumber(box.Text) < number then
view.Text = ("Higher")
end
end
end