ScriptConnection

ScriptConnection

Overview

Description

ScriptConnection represents a connection between a signal and a function callback in a script. It allows you to manage and disconnect the connection easily when it is no longer needed.

Constructors

Properties

Connected

boolean

Indicates whether the connection is currently active. A value of true means the connection is active, while false indicates that the connection has been disconnected.

Code Samples

local Players = game:GetService("Players")
local Connection = nil

local function EnterPlayer(player)
    print("EnterPlayer : ", player.Name)
end
Connection = Players.PlayerAdded:Connect(EnterPlayer)

if Connection.Connected then
    print("The connection is active.")
else
    print("The connection has been disconnected.")
end

Methods

Disconnect

Disconnects the connection between the signal and the function. Once disconnected, this connection cannot be reactivated.

Parameters

Return

void

Does not return a value.

Code Samples

Connection:Disconnect()

Last updated