Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Check if Part is on a part of the screen?

Hey! So I know I can use WorldToScreenPoint to check whether or not a Part is visible, and the position of it in 2D, but how would I manage to know if that Part is inside a circle on my screen?

Image:

https://i.gyazo.com/1e6404851183b4564322c35cfcf5ec8c.png

I don't want full script, I just need the calculation.

2 comments

0

link is said to be not valid

0

Maybe you could make a GUIs position on the part and then see if the GUIs in the circle

1 answer

Try using .magnitude. Take the position of the center of the circle and the position of the part and see if the magnitude is equal to or less than a certain number. Ex:

local Part = game.Workspace.Part
local MiddleOfCircle = game.Workspace.Circle.Position
local Radius = 15 -- Just an example

Part.Changed:Connect(function()
local Magnitude = (MiddleOfCircle - Part.Position).Magnitude
if Magnitude <= Radius then
Part.Transparency = 0
else
Part.Transparency = 1
end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.