ScriptConnection
Overview
ScriptConnection is a connection object that connects a function written in Lua script to an event.
This object is created when Connect is called and plays an important role in event management by providing a way to stop event handling using the Disconnect function.
Constructors
Properties
Connected
boolean
A property representing event connection status.
Returns false when the Disconnect method is called.
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.")
endMethods
Disconnect
Disconnects event and no longer receives the signal.
Parameters
Return
void
Code Samples
See also
EventLast updated