Skip to content

Commit 7d12a08

Browse files
Add a code example to RBXScriptConnection (#895)
## Changes <!-- Please summarize your changes. --> Added a code example for using RBXScriptConnection <!-- Please link to any applicable information (forum posts, bug reports, etc.). --> ## Checks By submitting your pull request for review, you agree to the following: - [x] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses. - [x] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses. - [x] To the best of my knowledge, all proposed changes are accurate. ---------
1 parent 3d8bf93 commit 7d12a08

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

content/en-us/reference/engine/datatypes/RBXScriptConnection.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@ type: datatype
33
summary: |
44
A connection between an `Datatype.RBXScriptSignal` and a function.
55
description: |
6-
The `Datatype.RBXScriptConnection` data type, also known as a Connection, is a
7-
special object returned by the Connect method of an Event
6+
The `RBXScriptConnection` data type is a special object returned by the
7+
`Datatype.RBXScriptSignal:Connect()|Connect()` method of an event
88
(`Datatype.RBXScriptSignal`). This is used primarily to disconnect a listener
99
from an `Datatype.RBXScriptSignal`.
10+
11+
```lua
12+
local part : BasePart = script.Parent
13+
-- Store reference to the RBXScriptConnection so it can be disconnected later
14+
local connection : RBXScriptConnection = part.Touched:Connect(function(otherPart)
15+
print("Hello world!")
16+
end)
17+
-- Wait 15 seconds, then disconnect
18+
task.wait(15)
19+
connection:Disconnect()
20+
```
1021
code_samples:
1122
tags: []
1223
deprecation_message: ''
@@ -18,8 +29,8 @@ properties:
1829
summary: |
1930
The state of the RBXScriptConnection.
2031
description: |
21-
Describes whether or not the connection is still alive. This becomes false
22-
if `connection:Disconnect()` is called.
32+
Describes whether or not the connection is still alive. This becomes `false`
33+
if `Datatype.RBXScriptConnection:Disconnect()|Disconnect()` is called.
2334
code_samples: []
2435
tags: []
2536
deprecation_message: ''

0 commit comments

Comments
 (0)