How do I destroy or disconnect a listening function/event like PropertyChangedSignal?

I tried to look at disconnecting a while ago and I couldn’t seem to wrap my head around it so I found alternative methods to certain problems.

however for this instance I’m trying to keep the camera in a stationary spot for a certain amount of time while a model moves also while also not utilizing any type of waits as those cause stuttering issues

currently my best solution is using propertychangedsignal, but I don’t know how to stop it from listening once a condition is met:

game.Workspace.Model.PrimaryPart:GetPropertyChangedSignal("Position"):Connect(function()
	camera.CFrame = game.Workspace.Model.CameraObjectInside.CFrame
end)

or will I have to simply make a contition and if true then do camera.cframe… else return? I’d rather not do that If I don’t have to but if it comes down to it, I may have to…

try creating a variable that represents the RBXSignalConnection.

ex:

local connection

connection = game.Workspace.Model.PrimaryPart:GetPropertyChangedSignal("Position"):Connect(function()
	camera.CFrame = game.Workspace.Model.CameraObjectInside.CFrame

    --disconnect the event
    connection:Disconnect()
end)
1 Like

thank you wow such an easy solution