@@ -3,16 +3,16 @@ type: class
33category : Utility
44memory_category : Instances
55summary : |
6- A service which manages object collections using assigned tags.
6+ A service which manages instance collections using assigned tags.
77description : |
8- `Class. CollectionService` manages groups (collections) of instances with
9- **tags**. Tags are sets of strings applied to objects that replicate from the
10- server to the client. They are also serialized when places are saved.
8+ `CollectionService` manages groups (collections) of instances with **tags**.
9+ Tags are sets of strings applied to instances that replicate from the server
10+ to the client. They are also serialized when places are saved.
1111
12- The primary use of `Class. CollectionService` is to register instances with
13- specific tags that you can use to extend their behavior. If you find yourself
14- adding the same script to many different objects, perhaps a script that uses
15- `Class. CollectionService` would be better.
12+ The primary use of `CollectionService` is to register instances with specific
13+ tags that you can use to extend their behavior. If you find yourself adding
14+ the same script to many different instances, a script that uses
15+ `CollectionService` may be better.
1616
1717 Tags can be added or removed through this class' methods such as
1818 `Class.CollectionService:AddTag()|AddTag()` or
@@ -22,12 +22,12 @@ description: |
2222 properties, or through the built‑in
2323 [Tag Editor](../../../studio/view-tab.md#windows-and-tools) tool.
2424
25- #### Replication
25+ ##### Replication
2626
27- When tags replicate, **all tags on an object replicate at the same time**.
28- Therefore, if you set a tag on an object from the client then add/remove a
29- **different** tag on the same object from the server, the client's local tags
30- on the object are overwritten. In
27+ When tags replicate, **all tags on an instance replicate at the same time**.
28+ Therefore, if you set a tag on an instance from the client then add/remove a
29+ **different** tag on the same instance from the server, the client's local
30+ tags on the instance are overwritten. In
3131 `Class.Workspace.StreamingEnabled|StreamingEnabled` places, instances can be
3232 unloaded as they leave the client's streamed area. If such an instance
3333 re-enters the streamed area, properties and tags will be re-synchronized from
@@ -46,10 +46,11 @@ methods:
4646 summary : |
4747 Applies a tag to an `Class.Instance`.
4848 description : |
49- AddTag will apply a tag to an `Class.Instance`, doing nothing if the tag
50- is already applied to the instance. Successfully adding a tag will fire a
51- signal created by `Class.CollectionService:GetInstanceAddedSignal()` with
52- the given tag.
49+ This method applies a tag to an `Class.Instance`, doing nothing if the tag
50+ is already applied to that instance. Successfully adding a tag will fire a
51+ signal created by
52+ `Class.CollectionService:GetInstanceAddedSignal()|GetInstanceAddedSignal()`
53+ with the given tag.
5354
5455 ##### Warnings
5556
@@ -61,9 +62,9 @@ methods:
6162 give the tag its functionality, for example event connections or tables.
6263 To prevent memory leaks, it's a good idea to clean these up (disconnect,
6364 set to `nil`, etc.) when no longer needed for a tag. Do this when
64- calling `Class.CollectionService:RemoveTag()`, calling
65+ calling `Class.CollectionService:RemoveTag()|RemoveTag() `, calling
6566 `Class.Instance:Destroy()` or in a function connected to a signal
66- returned by `Class.CollectionService:GetInstanceRemovedSignal()`.
67+ returned by `Class.CollectionService:GetInstanceRemovedSignal()|GetInstanceRemovedSignal() `.
6768 code_samples :
6869 parameters :
6970 - name : instance
@@ -85,8 +86,10 @@ methods:
8586 capabilities : []
8687 writeCapabilities : []
8788 - name : CollectionService:GetAllTags
88- summary : ' '
89- description : ' '
89+ summary : |
90+ Returns an array of all tags in the experience.
91+ description : |
92+ Returns an array of all tags in the experience.
9093 code_samples : []
9194 parameters : []
9295 returns :
@@ -128,23 +131,27 @@ methods:
128131 writeCapabilities : []
129132 - name : CollectionService:GetInstanceAddedSignal
130133 summary : |
131- Returns a signal that fires when a given tag is added to an object .
134+ Returns a signal that fires when a given tag is added to an instance .
132135 description : |
133- GetInstanceAdded is given a tag (a string) and returns a signal which
134- fires under two conditions:
136+ Given a tag (string), this method returns a signal which fires under two
137+ conditions:
138+
139+ - The tag is assigned to an instance within the `Class.DataModel` using
140+ `Class.CollectionService:AddTag()` or `Class.Instance:AddTag()`.
135141
136- - The tag is assigned to an instance within the `Class.DataModel` (game)
137- using `Class.CollectionService:AddTag()` or `Class.Instance:AddTag()`.
138142 - An instance with the given tag is added as a descendant of the
139- `Class.DataModel`, e.g. by setting `Class.Instance.Parent` or similar.
143+ `Class.DataModel`, for example by setting `Class.Instance.Parent` or
144+ similar.
140145
141146 Subsequent calls to this method with the same tag return the same signal
142- object. Consider also calling `Class.CollectionService:GetTagged()` to get
143- a list of objects that already have a tag (and thus won't fire the event
144- if they already are in the `Class.DataModel`).
147+ object. Consider also calling
148+ `Class.CollectionService:GetTagged()|GetTagged()` to get a list of
149+ instances that already have a tag (and thus won't fire the event if they
150+ already are in the `Class.DataModel`).
145151
146- See also `Class.CollectionService:GetInstanceRemovedSignal()`, which
147- returns an event that fires under similar conditions.
152+ See also
153+ `Class.CollectionService:GetInstanceRemovedSignal()|GetInstanceRemovedSignal()`
154+ which returns an event that fires under similar conditions.
148155 code_samples :
149156 - Deadly-Bricks-using-CollectionService
150157 parameters :
@@ -167,22 +174,22 @@ methods:
167174 summary : |
168175 Returns a signal that fires when a given tag is removed from an instance.
169176 description : |
170- GetInstanceRemoved is given a tag (a string) and returns a signal which
171- fires under two conditions:
177+ Given a tag (string), this method returns a signal which fires under two
178+ conditions:
179+
180+ - The tag is removed from an instance within the `Class.DataModel` using
181+ `Class.CollectionService:RemoveTag()` or `Class.Instance:RemoveTag()`.
172182
173- - The tag is removed from an instance within the `Class.DataModel` (game)
174- using `Class.CollectionService:RemoveTag()` or
175- `Class.Instance:RemoveTag()`.
176183 - An instance with the given tag is removed as a descendant of the
177- `Class.DataModel`, e.g. by un-setting `Class.Instance.Parent` or
178- similar.
184+ `Class.DataModel`, for example by un‑setting `Class.Instance.Parent` or similar.
179185
180186 Subsequent calls to this method with the same tag return the same signal
181- object. The signal is useful for cleaning up resources used by objects
187+ object. The signal is useful for cleaning up resources used by instances
182188 that once had tags, such as disconnecting connections.
183189
184- See also `Class.CollectionService:GetInstanceAddedSignal()`, which returns
185- an event that fires under similar conditions.
190+ See also
191+ `Class.CollectionService:GetInstanceAddedSignal()|GetInstanceAddedSignal()`
192+ which returns an event that fires under similar conditions.
186193 code_samples :
187194 - Deadly-Bricks-using-CollectionService
188195 parameters :
@@ -203,24 +210,22 @@ methods:
203210 writeCapabilities : []
204211 - name : CollectionService:GetTagged
205212 summary : |
206- Returns an array of objects in the game with a given tag.
213+ Returns an array of instances in the game with a given tag.
207214 description : |
208- GetTagged returns an array of objects with a given tag which are
209- descendants of the `Class.DataModel` (`game`). Such tags have been added
210- using `Class.CollectionService:AddTag()`, and removing a tag using
211- `Class.CollectionService:RemoveTag()` will ensure this method does not
212- return them. Although the name of this method is past-tense, this method
213- only returns objects **presently** tagged with the given tag. It will not
214- return objects that once had a tag but no longer have it.
215+ This method returns an array of instances with a given tag which are
216+ descendants of the `Class.DataModel`. Removing a tag using
217+ `Class.CollectionService:RemoveTag()` or `Class.Instance:RemoveTag()`
218+ ensures this method does not return them.
215219
216- If you want to detect all objects with a tag, both present and future, use
217- this method to iterate over objects while also making a connection to a
218- signal returned by `Class.CollectionService.GetInstanceAddedSignal`.
220+ If you want to detect all instances with a tag, both present **and**
221+ future, use this method to iterate over instances while also making a
222+ connection to a signal returned by
223+ `Class.CollectionService:GetInstanceAddedSignal()|GetInstanceAddedSignal()`.
219224
220- This method does not guarantee any ordering of the returned objects .
221- Additionally, it is possible that objects can have the given tag assigned
222- to them, but not be a descendant of the `Class.DataModel`, i.e. its parent
223- is nil. This method will not return such objects .
225+ This method does not guarantee any ordering of the returned instances .
226+ Additionally, it's possible that instances can have the given tag assigned
227+ to them but not be a descendant of the `Class.DataModel`, for example its
228+ parent is ` nil`; this method will not return such instances .
224229 code_samples :
225230 - Deadly-Bricks-using-CollectionService
226231 parameters :
@@ -241,36 +246,27 @@ methods:
241246 writeCapabilities : []
242247 - name : CollectionService:GetTags
243248 summary : |
244- Gets an array of all tags applied to a given object .
249+ Gets an array of all tags applied to a given instance .
245250 description : |
246- GetTags is given an instance and returns an array of strings, which are
247- the tags applied to the given object .
251+ Given an `Class.Instance`, this method returns an array of strings which
252+ are the tags applied to the instance .
248253
249- ```
250- local CollectionService = game:GetService("CollectionService")
251- local Workspace = game:GetService("Workspace")
252-
253- local object = Workspace.Model
254- local tags = CollectionService:GetTags(object)
255- print("The object " .. object:GetFullName() .. " has tags: " .. table.concat(tags, ", "))
256- ```
257-
258- This method is useful when you want to do something with multiple tags at
259- once on an object. However, it would be inefficient to use this method to
260- check for the existence of a single tag. For this, use
261- `Class.CollectionService:HasTag()` to check for a single tag.
254+ This method is useful when you want to do something with multiple instance
255+ tags at once, but it's inefficient to check for the existence of a single
256+ tag. For this, use `Class.CollectionService:HasTag()|HasTag()` to check
257+ for a single tag.
262258 code_samples :
263259 - Using-Tags-and-CollectionService
264260 parameters :
265261 - name : instance
266262 type : Instance
267263 default :
268264 summary : |
269- The object whose tags should be returned.
265+ The instance whose tags should be returned.
270266 returns :
271267 - type : Array
272268 summary : |
273- An array of strings which are the tags applied to the given object .
269+ An array of strings which are the tags applied to the given instance .
274270 tags :
275271 - CustomLuaState
276272 deprecation_message : ' '
@@ -280,18 +276,13 @@ methods:
280276 writeCapabilities : []
281277 - name : CollectionService:HasTag
282278 summary : |
283- Check whether an object has a given tag.
279+ Check whether an instance has a given tag.
284280 description : |
285- HasTag returns whether a given object has a tag.
286-
287- - Using `Class.CollectionService:AddTag()` to add the tag will cause this
288- method to return true.
289- - Using `Class.CollectionService:RemoveTag()` to remove the tag will cause
290- this method to return false.
281+ This method returns whether a given `Class.Instance` has a tag.
291282
292283 By extension, any tags returned by a call to
293- `Class.CollectionService:GetTags()` on an object will return true when
294- used with this method.
284+ `Class.CollectionService:GetTags()|GetTags() ` on an instance will return
285+ `true` when used with this method.
295286 code_samples :
296287 - Using-Tags-and-CollectionService
297288 parameters :
@@ -320,15 +311,15 @@ methods:
320311 summary : |
321312 Removes a tag from an instance.
322313 description : |
323- RemoveTag will remove a tag from an instance. This method will not throw
324- an error if the object did not have the tag in the first place.
325- Successfully removing a tag will fire a signal created by
326- `Class.CollectionService:GetInstanceRemovedSignal()` with the given tag.
314+ This method removes a tag from an instance. Successfully removing a tag
315+ will fire a signal created by
316+ `Class.CollectionService:GetInstanceRemovedSignal()|GetInstanceRemovedSignal()`
317+ with the given tag.
327318
328- When removing a tag, it is common that some resources are used to give the
329- tag its functionality, e.g. event connections or tables. To prevent memory
330- leaks, it is a good idea to clean these up (disconnect, set to nil, etc)
331- when no longer needed for a tag.
319+ When removing a tag, it's common that some resources are used to give the
320+ tag its functionality, for example event connections or tables. To prevent
321+ memory leaks, it's a good idea to clean these up (disconnect, set to
322+ `nil`, etc.) when no longer needed for a tag.
332323 code_samples :
333324 - Using-Tags-and-CollectionService
334325 parameters :
@@ -405,11 +396,11 @@ events:
405396 writeCapabilities : []
406397 - name : CollectionService.TagAdded
407398 summary : |
408- Fires when a tag is added to an object and the added tag is the only
399+ Fires when a tag is added to an instance and the added tag is the only
409400 occurrence of that tag in the place.
410401 description : |
411- This event fires when a tag is added to an object and the added tag is the
412- only occurrence of that tag in the place.
402+ This event fires when a tag is added to an instance and the added tag is
403+ the only occurrence of that tag in the place.
413404 code_samples : []
414405 parameters :
415406 - name : tag
@@ -424,11 +415,11 @@ events:
424415 writeCapabilities : []
425416 - name : CollectionService.TagRemoved
426417 summary : |
427- Fires when a tag is removed from an object and the removed tag is no
418+ Fires when a tag is removed from an instance and the removed tag is no
428419 longer used anywhere in the place.
429420 description : |
430- This event fires when a tag is removed from an object and the removed tag
431- is no longer used anywhere in the place.
421+ This event fires when a tag is removed from an instance and the removed
422+ tag is no longer used anywhere in the place.
432423 code_samples : []
433424 parameters :
434425 - name : tag
0 commit comments