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 » Game Design
Home Search
 

Re: Print touching parts name using an if statement?

Previous Thread :: Next Thread 
CreateTycoons is not online. CreateTycoons
Joined: 16 Aug 2016
Total Posts: 6
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
enzotinman1 is not online. enzotinman1
Joined: 22 Jun 2012
Total Posts: 408
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
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
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 is not online. 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
CrixusOdalisManiatus is not online. CrixusOdalisManiatus
Joined: 16 Jun 2011
Total Posts: 5987
24 Aug 2016 05:35 AM
is this a while do function?
or a simple ontouch
Report Abuse
Mitko0o1 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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