How do I check given a vector2 if it’s within a frame inside the screen or not and keep in mind I want it to take into account resolution how would I do it?
You can use the absolute position and absolute size of the frame. Then just compare thd points to those. Like do
local testPoint = inputVec -frame.AbsolutePosition
if testPoint.X >= 0 and testPoint.Y >= 0 then
return (testPoint.X <= frame.AbsoluteSize.X and testPoint.Y <= frame.absoluteSize.Y)
end
return false
it doesn’t work look
https://gyazo.com/aa3612dacc4e71ec356e1bd0f9a419fc
it somewhy says inside if I am right of it
Works fine for me. You might be having issues with the GUI inset which breaks everything and makes no sense.
local function isPointInFrame(vec2, frame)
local testPoint = vec2 -frame.AbsolutePosition
if testPoint.X >= 0 and testPoint.Y >= 0 then
return (testPoint.X <= frame.AbsoluteSize.X and testPoint.Y <= frame.absoluteSize.Y)
end
return false
end
local UserInputService = game:GetService("UserInputService")
local inset = game:GetService("GuiService"):GetGuiInset()
game:GetService("RunService").Heartbeat:Connect(function()
local mouse = UserInputService:GetMouseLocation() - inset
if isPointInFrame(mouse, script.Parent.Frame) then
script.Parent.Frame.BackgroundColor3 = Color3.new(0,1,0)
else
script.Parent.Frame.BackgroundColor3 = Color3.new(1, 0, 0)
end
end)
what is gui insect and how can I use it to fix it
got it to be fixed(no idea how on god) with insect but complete your reply have no idea wht insect is

That frame is at position 0,0. Gui inset simply describes that offset that is applied automatically. So by substracting the inset vector from the mouse position you can make it actually accurate. The code I provided does that for example.
You are one smart guy, check if you can help me out on this
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.