Hi, I was working on this system that checks if the player mouse is on a UI frame. I wanted to use the player mouse, get the X and Y position and check if those are ontop of the frame. But now it does nothing
This is my code:
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.Button1Down:Connect(function()
local Blocks = script.Parent:GetChildren()
for _, B in pairs(Blocks) do
if B:IsA("Script") then
table.remove(Blocks, B)
else
local X = Mouse.X
local Y = Mouse.Y
for _, B2 in pairs(Blocks) do
local B2SizeX = B2.Size.X
local B2SizeY = B2.Size.Y
local B2PositionX = B2.Position.X
local B2PositionY = B2.Position.Y
local MaxX = B2PositionX + B2SizeX
local MaxY = B2PositionY + B2SizeY
local MinX = B2PositionX
local MinY = B2PositionY
if X >= MinX or X <= MaxX and Y >= MinY or Y <= MaxY then
print("Mouse is on top of "..B2.Name)
end
end
end
end
end)
Does someone maybe know how this works?