File tree Expand file tree Collapse file tree 4 files changed +20
-21
lines changed
tutorials/fundamentals/coding-5 Expand file tree Collapse file tree 4 files changed +20
-21
lines changed Original file line number Diff line number Diff line change @@ -51,10 +51,16 @@ methods:
5151 signal created by `Class.CollectionService:GetInstanceAddedSignal()` with
5252 the given tag.
5353
54- **Warning:** When tagging an instance, it is common that some resources
55- are used to give the tag its functionality, e.g. event connections or
56- tables. To prevent memory leaks, it is a good idea to clean these up
57- (disconnect, set to nil, etc) when no longer needed for a tag. Do this
54+ ##### Warnings
55+
56+ - An instance's tags that were added client-side will be dropped if the server
57+ later adds or removes a tag on that instance because the server replicates all
58+ tags together and overwrites previous tags.
59+
60+ - When tagging an instance, it is common that some resources
61+ are used to give the tag its functionality, for example event connections or
62+ tables. To prevent memory leaks, it's a good idea to clean these up
63+ (disconnect, set to `nil`, etc.) when no longer needed for a tag. Do this
5864 when calling `Class.CollectionService:RemoveTag()`, calling
5965 `Class.Instance:Destroy()` or in a function connected to a signal returned
6066 by `Class.CollectionService:GetInstanceRemovedSignal()`.
Original file line number Diff line number Diff line change @@ -321,7 +321,13 @@ methods:
321321 already applied. Successfully adding a tag will fire a signal created by
322322 `Class.CollectionService:GetInstanceAddedSignal()` with the given tag.
323323
324- Note that when tagging an instance, it's common that some resources are
324+ ##### Warnings
325+
326+ - An instance's tags that were added client-side will be dropped if the server
327+ later adds or removes a tag on that instance because the server replicates
328+ all tags together and overwrites previous tags.
329+
330+ - When tagging an instance, it is common that some resources are
325331 used to give the tag its functionality, for example event connections or
326332 tables. To prevent memory leaks, it's a good idea to clean these up
327333 (disconnect, set to `nil`, etc.) when no longer needed for a tag. Do this
Original file line number Diff line number Diff line change @@ -234,11 +234,7 @@ sound:Play()
234234-- Start checking if emitter should be enabled
235235RunService .Heartbeat :Connect (function ()
236236 -- Enable the emitter within a time range of the audio; otherwise disable it
237- if sound .TimePosition >= 5 and sound .TimePosition < 20 then
238- emitter .Enabled = true
239- else
240- emitter .Enabled = false
241- end
237+ emitter .Enabled = sound .TimePosition >= 5 and sound .TimePosition < 20
242238end )
243239```
244240
Original file line number Diff line number Diff line change @@ -202,11 +202,7 @@ Use the array size to check when it's time to cycle back to the first piece of d
202202 local dialogue = dialogueArray [dialogueIndex ]
203203 Chat :Chat (head , dialogue )
204204
205- if dialogueIndex == # dialogueArray then
206- dialogueIndex = 1
207- else
208- dialogueIndex += 1
209- end
205+ dialogueIndex = if dialogueIndex == # dialogueArray then 1 else dialogueIndex + 1
210206 end
211207 ```
212208
@@ -239,12 +235,7 @@ This script used an array to create a list of possible dialogue lines for a Non-
239235 local dialogue = dialogueArray [dialogueIndex ]
240236 Chat :Chat (head , dialogue )
241237
242- if dialogueIndex == # dialogueArray then
243- dialogueIndex = 1
244-
245- else
246- dialogueIndex += 1
247- end
238+ dialogueIndex = if dialogueIndex == # dialogueArray then 1 else dialogueIndex + 1
248239 end
249240
250241 prompt .Triggered :Connect (speak )
You can’t perform that action at this time.
0 commit comments