How to know if player is in this

Untitled

basically what i want is if the player is inside the triangle like thingy they will be blind
for e.g

Thats a good question. It’s getting late, so I won’t be able to provide more exact solutions than this.

But since it is a triangle, you should be able to calculate whether the position is within a triangle. Start by defining the three points as something easy to count with, such as

  • (0, 0, 0)
  • (-5, 0, 0)
  • (5, 0, 0)
    This should make a triangle. Try different positions which you know are within these, then try spotting a pattern.

I’m sure someone else can help you with the math of this, but hopefully this is of some help at the very least.

1 Like

Hi,

you can use Region3 for doing so.
You can detect whenever a player is in that region, and when he is there ,you could do your stuff.

2 Likes

You could always put a transparent triangle which is brought out of replicatedstorage and weld it to the head cframe. Then the triangle has a touched event which does whatever you want it to

1 Like

Region3 is rectangular, while it is a good suggestion and very useful in many cases, I’m not sure it is the right tool for the job.

“Creates a new Region3 given the Vector3 bounds of a the rectangular prism volume.”

Creating triangle is very much a viable alternative, however creating parts may potentially cause issues. If it has canCollide on then all players within that area will get stuck and possibly flung. To avoid this you might be able to simply set canCollide false and use the following:

workspace:GetPartsInPart(<yourTriangle>) -- Gives table of parts

Creating parts is generally more resource intensive than math, but usually its not enough to the trouble of figuring out the math.

In this case I’d:

  • Create triangle
  • Set canCollde to false
  • Set Parent to Workspace
  • call workspace:GetPartsInPart()
  • Find players from the list
  • Blind players
1 Like