I’m trying to check if a player clicked near a part not just on it. No idea how to do this but I know there is worldtoscreenpoint.
Look into Mouse.Button1Down.
Either you can add transparent part which detects the click instead - like a bigger collider, or if it’s just one specific part then you can use something like
if (mouse.Hit.Position - targetPart.Position).magnitude < 5 then
which just checks if the part is within 5 studs of the click position
this is great but the thing is if i were to click in the air right next to the part it wouldnt work, it would have to be on another part near it.
maybe there is a way to get it just on screen position?
Yeah, sorry for that, then I would just go with the first option of creating a part that just functions as an extra collider. I guess it would be possible to calculate the distance of the part from the camera and determine the raycast ray length that way but it’s up to you.
im going to try using Camera:WorldToScreenPoint
Let me know how it goes. Right now I have no idea how to do that reliably with WorldToScreenPoint since it calculates only one point on the screen. You would have to somehow adjust the acceptable magnitude of (mousePosition - point) according to the depth since the point’s X and Y can remain the same as you get closer but the object get bigger on screen with decreasing depth (Z)
yeah tbh i dont know either, ill mess around with it tho and see if anything comes out of it.
Just an example with my original solution Video (294.4 KB)
The only indicator of it being clickable is the cursor change btw lol
since I also need this to work on all players im going to try that with playersadded and add that hitbox.
Well I made it so that the part is there to begin with in the model itself and just contains click detector