|
| 23 Aug 2016 11:39 PM |
How would I do this -
if part is touching other part then print(other part.Name) end
I basically want to detect if a part is touching another part, and if it is, print that parts name. Also, I'd like it to be an if statement. |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2016 11:43 PM |
http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched
bash an if statement in there. |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2016 11:50 PM |
http://wiki.roblox.com/index.php?title=API:Class/BasePart/GetTouchingParts
Returns an array of parts touching the part of interest. |
|
|
| Report Abuse |
|
|
Scottifly
|
  |
| Joined: 30 Jan 2011 |
| Total Posts: 9180 |
|
|
| 24 Aug 2016 02:34 AM |
Do you want to have it scripted for reasons in game or do you just want to see the contact points? If you only want to see if Parts are touching in Studio you can click on your Tools, then click Settings and go to the Physics tab:
http://wiki.roblox.com/index.php?title=API:Class/PhysicsSettings
Check the 'AreContactPointsShown' box. You won't have to get out of Studio for them to show up, the message that pops up isn't there for this item.
When you Play the game (F6) then all the contact points in game will show up with green spheres on them. |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2016 05:35 AM |
is this a while do function? or a simple ontouch |
|
|
| Report Abuse |
|
|
Mitko0o1
|
  |
| Joined: 30 Nov 2010 |
| Total Posts: 5725 |
|
|
| 24 Aug 2016 07:18 AM |
function printPartName(part) if part ~= nil then print(script.Parent.Name .. " was just touched by " .. part.Name) end end
script.Parent.Touched:connect(printPartName)
Some pages that may help you understand this code:
http://wiki.roblox.com/index.php?title=Function http://wiki.roblox.com/index.php?title=API:Class/BasePart/Touched http://wiki.roblox.com/index.php?title=Conditional_statement&redirect=no
am triggered |
|
|
| Report Abuse |
|
|