API:Class/BasePart/Touched

< API:Class‎ | BasePart
Revision as of 20:59, 7 January 2016 by UristMcSparks (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Touched

Event of Object Icon.pngBasePart
There are members of the same name. See the disambiguation page.
RBXScriptSignal Touched (
    BasePart otherPart
)
Parameters:
  1. otherPart

Description: Fired when another object comes in contact with this object.

Notes

  • This event does not fire if the part is being CFramed through something.
  • Lots of objects (such as projectiles in weapons) have scripts that remove a part as soon as it hits something. This means that it is possible for the otherPart argument's Parent to be nil. Scripts that use the Touched event should check for this, otherwise they will break if they try to use members of otherPart's parent.

Example

This code would print the name of any object touching the part:

Workspace.Part.Touched:connect(function(otherPart)
  print(otherPart)
end)

Tutorials Used In