PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetInstanceAddedSignal

GetInstanceAdded is given a tag (a string) and returns a signal which fires under two conditions:

  • The tag is assigned to an object within the DataModel (game) using CollectionService/AddTag
  • An object with the given tag is added as a descendant of the DataModel, e.g. by setting Instance/Parent or similar

Subsequent calls to this method with the same tag return the same signal object. Consider also calling CollectionService/GetTagged to get a list of objects that already have a tag (and thus won’t fire the event if they already are in the DataModel).

See also CollectionService/GetInstanceRemovedSignal, which returns an event that fires under similar conditions.

Parameters

Name Type Default Description

tag

Returns

Return Type Summary

Code Samples


Deadly Bricks using CollectionService

This code sample causes any BasePart with the tag “Deadly” to kill any Humanoid that touches it. It does this using a common pattern with CollectionService: listen for all parts with the tag, and make a connection. When the tag is removed, disconnect. Instead of copying the same kill script into many bricks, use this pattern instead!