generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Detecting if play is inside part/Union?

Previous Thread :: Next Thread 
kidchaos24 is not online. kidchaos24
Joined: 02 Feb 2011
Total Posts: 169
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 is not online. ELETROG
Joined: 11 Jul 2013
Total Posts: 604
09 Sep 2014 02:27 PM
Well yes. You were right. This is confusing.
Report Abuse
kidchaos24 is not online. kidchaos24
Joined: 02 Feb 2011
Total Posts: 169
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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image