Hello, this is my first Topic so please be sure to tell me if I’m doing something wrong.
I’m trying to create a mirror module script for houses. I have most of it down, and I’m almost done, but I have an issue. You see, I’m trying to make it so if players pass through the area where a player might be looking through, I want them to go invisible, so they can’t disrupt the reflection. The problem is that I want the regions that check if the player is inside them to be able to be rotated, and what I have been using, Region3 can’t do rotations, so I had to result to GetTouchingParts (Which is much more expensive). Because this runs every RunService Heartbeat, the game lags a lot when trying to find who is inside.
Aside from that, here’s the main question.
Is there a way to check for player’s in a rotated region (by the way, the region is based on a part)
Or, way more simply, if the part’s a rectangle and you can simplify the question to “is the position of a player inside this part”:
local function IsPointInsidePart(point, part)
local relative = part.CFrame:PointToObjectSpace(point)
local halfSize = part.Size / 2
return relative.X >= -halfSize.X and relative.X <= halfSize.X
and relative.Y >= -halfSize.Y and relative.Y <= halfSize.Y
and relative.Z >= -halfSize.Z and relative.Z <= halfSize.Z
end
A very easy way I have learned is that if you toggle collision on and off .Touched will fire. As you flick it on and off so quick it means that it wont effect anything it touches either.