How to use an if statement with a NumberRange

So I’m trying to make minesweeper, and I’ve got most of it down, but the only thing I’m having trouble with is the detection of other UI elements. Since the grid I’m using doesn’t get them on a whole number, it means some of the absolute positions are decimals. So I tried to get around that by using math.ceil, but it turns out that on certain rows, they’re more than a decimal apart (some rows it does work). So I turned to NumberRange. I’ve tried working it out, but I can’t figure out how to compare a set number, and what the NumberRange gives me. Here is my code: (The placement of the other squares are around 1-2 numbers apart, but I gave it the 20 number range because I had the room)

local square = script.Parent
local gameArea = script.Parent.Parent

local bombsAround = 0

function checkBelow()
	local belowSquare = NumberRange.new(square.AbsolutePosition.Y+20,square.AbsolutePosition.Y+40)
	for _,newSquare in pairs(gameArea:GetChildren()) do
		if newSquare:IsA("TextButton")then
			if math.ceil(newSquare.AbsolutePosition.Y) == belowSquare and math.ceil(newSquare.AbsolutePosition.X) == math.ceil(square.AbsolutePosition.X) then
				if newSquare:GetAttribute("IsBomb") == true then
					bombsAround = bombsAround + 1
				end
			end
		end
	end
end

Any help is appreciated!

1 Like