Hi everyone! I recently created gui boundaries for my drawing system however, the y axis boundary is not working properly. Here is my code:
local module = {}
local function convertOffPosToScaleX(x, root)
local totalX = root
local finalX = x/totalX
return finalX
end
local function convertOffPosToScaleY(y, root)
local totalY = root
local finaly = y/totalY
return finaly
end
function module.checkBound(SquarePos, SquareSize, mouseX, mouseY)
local xMin, xMax = SquarePos.X.Scale-(SquareSize.X.Scale)/2, SquarePos.X.Scale+(SquareSize.X.Scale)/2
local yMin, yMax = SquarePos.Y.Scale-((SquareSize.Y.Scale)/2), SquarePos.Y.Scale+((SquareSize.Y.Scale)/2)
local newMouseX = convertOffPosToScaleX(mouseX,script.Parent.Parent.DrawingFrame.AbsoluteSize.X)
local newMouseY = convertOffPosToScaleX(mouseY,script.Parent.Parent.DrawingFrame.AbsoluteSize.Y)
if newMouseX > xMin and newMouseX<xMax then
if newMouseY > yMin and newMouseY<yMax then
print(yMin,newMouseY,yMax)
return true
end
end
end
return module