|
| 09 Sep 2014 01:43 PM |
I'm trying to write a script to detect if a player is inside of my union/part but i've become completely lost on how I would go about doing this. I know touched and touchend is involved. Simply I want playerA to walk in to this union/part and playerB to have "attacks" which can only be used on playerA when playerB is INSIDE of the union/part. |
|
|
| Report Abuse |
|
|
ELETROG
|
  |
| Joined: 11 Jul 2013 |
| Total Posts: 604 |
|
|
| 09 Sep 2014 02:27 PM |
| Well yes. You were right. This is confusing. |
|
|
| Report Abuse |
|
|
|
| 09 Sep 2014 02:34 PM |
Made a slight mistake on the last example! Simply I want playerA to walk in to this union/part and playerB to have "attacks" which can only be used on playerA when INSIDE of the union/part. |
|
|
| Report Abuse |
|
|
DevFrank
|
  |
| Joined: 04 Apr 2012 |
| Total Posts: 1469 |
|
|
| 09 Sep 2014 02:51 PM |
you could do below, IT'S only a example.
local Parts = game.Workspace:GetChildren() for i = 1,#Parts do if Parts[i]:IsA("Union Operation") then Parts[i].BrickColor = BrickColor.new("Bright blue") |
|
|
| Report Abuse |
|
|
DevFrank
|
  |
| Joined: 04 Apr 2012 |
| Total Posts: 1469 |
|
|
| 09 Sep 2014 02:52 PM |
If you want it with ends then:
local Parts = game.Workspace:GetChildren() for i = 1,#Parts do if Parts[i]:IsA("Union Operation") then Parts[i].BrickColor = BrickColor.new("Bright blue") end end |
|
|
| Report Abuse |
|
|
ohno1112
|
  |
| Joined: 23 Mar 2013 |
| Total Posts: 833 |
|
|
| 09 Sep 2014 03:10 PM |
I know touched and touchend is involved.
Not exactly according to my method.
it involves using a Region3 area and check if the player is in it. see
http://wiki.roblox.com/index.php/Region3 and http://wiki.roblox.com/index.php?title=FindPartsInRegion3
make a part the smallest you can, and note down 2 Vector3 positions, then use that to create a region3. for example
region = Region3.new(Vector3.new(0,0,0),Vector3.new(10,10,10))
Note that the first Vector3 must have a lower value in ALL dimensions than the second. 0,0,0 and 10,10,10 works, but 0,20,0 and 10,15,10 won't.
once you defined a region3, do this:
(in this example, variable = Region)
for _,Part in pairs(game.Workspace:FindPartsInRegion3(Region,nil,100)) do if Part.Parent.Name == player.name then
seems a little bit advanced, but once you got it down there's no preciser way to check what and if something is in a certain area. |
|
|
| Report Abuse |
|
|