Attempt to compare number with boolean?

I am trying to use functions to add or subtract a number value but keep it in between 0 and 20, and use a separate function to change the value to 1 if the value is too high or low, however when checking the value it apparently says it’s a boolean yet it’s a number value instance??

function Select()
	if scrollVal == 0 or nil then scrollVal = 1 return else
local	selected = screen.Frame:FindFirstChild(tostring(scrollVal))
	print (selected)
	selected.Text = "wai"
end
end

function Up()
	
	if scrollVal == scrollVal > 20 then scrollVal = 1 return
		else
scrollVal =  scrollVal + 1 
Select()
end
end

function Down()
	
	if scrollVal == scrollVal < 1   then scrollVal = 1 return
		else
scrollVal =  scrollVal - 1 
Select()

end
end

	
    script.Parent.Up.OnServerEvent:connect(function(player) 
        Up()
end) 
    script.Parent.Down.OnServerEvent:connect(function(player) 
        Down()
end)

If scrolval > 20

not if scrollval == scrollval > 20

I was trying not to spoon feed him :slight_smile: lol

one last thing, Since I got the solution.
The error is because if x == y then is a yes or no question (boolean)

So basically you asked:
if true is greater than 20

7 Likes

I believe this is because of this part of your code:

I’m not entirely sure what you’re trying to accomplish here. Right now, you’re checking if scollVal equals itself, and then comparing the boolean result from that with 20.

If you’re trying to check if scrollVal is greater than 20, just put if scrollVal > 20 then scollVal = 1 return.

Full Corrected(?) Script
function Select()
	if scrollVal == 0 or nil then scrollVal = 1 return else
local	selected = screen.Frame:FindFirstChild(tostring(scrollVal))
	print (selected)
	selected.Text = "wai"
end
end

function Up()
	
	if scrollVal > 20 then scrollVal = 1 return
		else
scrollVal =  scrollVal + 1 
Select()
end
end

function Down()
	
	if scrollVal < 1   then scrollVal = 1 return
		else
scrollVal =  scrollVal - 1 
Select()

end
end

	
    script.Parent.Up.OnServerEvent:connect(function(player) 
        Up()
end) 
    script.Parent.Down.OnServerEvent:connect(function(player) 
        Down()
end)
3 Likes