Connection wont disconnect after the second time it was connected

What do you want to achieve? Keep it simple and clear!

I was making a round based system if one team won the match it will make the camera cframe to a parts cframe

What is the issue? Include screenshots / videos if possible!

I was using connections to disconnect/connect the RenderStepped function
but once i try it at first time it actually disconnects but the second time it didnt work

THE CODE

local RS = game:GetService("ReplicatedStorage") local gameEvent = RS:WaitForChild("GameEvent") local camera = workspace.CurrentCamera local campart = workspace.CamPart local connection local renderconnection local Intermission = true connection = camera:GetPropertyChangedSignal("CameraType"):Connect(function()	if camera.CameraType ~= Enum.CameraType.Scriptable then	camera.CameraType = Enum.CameraType.Scriptable	end end) renderconnection = game:GetService("RunService").RenderStepped:Connect(function()	camera.CameraType = Enum.CameraType.Scriptable	camera.CFrame = campart.CFrame end) gameEvent.OnClientEvent:Connect(function(intermission)	if intermission == false then	print(intermission)	Intermission = intermission	connection:Disconnect()	renderconnection:Disconnect()	elseif intermission == true then	Intermission = intermission	print(intermission)	connection = camera:GetPropertyChangedSignal("CameraType"):Connect(function()	if camera.CameraType ~= Enum.CameraType.Scriptable then	camera.CameraType = Enum.CameraType.Scriptable	end	end)	renderconnection = game:GetService("RunService").RenderStepped:Connect(function()	camera.CameraType = Enum.CameraType.Scriptable	camera.CFrame = campart.CFrame	end)	print(connection, renderconnection)	end end) 
2 Likes
 -- Script inside the Part local part = script.Parent -- Function to handle the click event local function onClicked() print("Part clicked!") part.BrickColor = BrickColor.random() -- Change to a random color end -- Variable to store the connection local clickConnection -- Function to connect the click event local function connectClickEvent() if clickConnection then clickConnection:Disconnect() -- Disconnect the existing connection if any end clickConnection = part.ClickDetector.MouseClick:Connect(onClicked) print("Event connected") end -- Ensure the part has a ClickDetector if not part:FindFirstChild("ClickDetector") then local clickDetector = Instance.new("ClickDetector") clickDetector.Parent = part end -- Connect the click event initially connectClickEvent() -- Example of reconnecting the event (for demonstration purposes) -- In practice, you would call `connectClickEvent` wherever you need to ensure the event is reconnected wait(5) connectClickEvent() 
2 Likes

man thats literally what the my code is doing give some explanation man.

it don’t work

[its the same code(connnection code i was making)]

please give an indirect explanation

2 Likes

Can you print out the .Connected of the RBXScriptConnections?

print(connection and connection.Connected, renderconnection and renderconnection.Connected)

when intermission is false it printed true true

if intermission is true it printed

false false

You are have add something wrong check script maybe

Could you please add a print when the intermission ends and when you disconnect the remotes?

before disconnect it print true true after it after it disconnects it print false false

the second try it printed true true then false false again