Possible bug with disconnecting rbxscriptconnections

Why isnt the connection disconnecting?

pcall(function()
						airConnection = game:GetService("RunService").Stepped:Connect(function()
						
						if not char or not v or hum.Health == 0 or v.Parent.Humanoid.Health == 0 then airConnection:Disconnect()
							char:SetAttribute("InAir", false)
							print("changed from stupid air connection")
							if char.HumanoidRootPart:FindFirstChild("AlignPosition") then
								char.HumanoidRootPart:FindFirstChild("AlignPosition"):Destroy()
							end
						end
						if tick() - lastAirAttack >= 1 then
							if v.Parent.HumanoidRootPart:FindFirstChild("AlignPosition") and char:GetAttribute("HyperArmor") then
								v.Parent.HumanoidRootPart:FindFirstChild("AlignPosition"):Destroy()
							end
							if char.HumanoidRootPart:FindFirstChild("AlignPosition") and char:GetAttribute("HyperArmor") then
								print("deletedFromAirAttack")
								char.HumanoidRootPart:FindFirstChild("AlignPosition"):Destroy()
							end
							char:SetAttribute("InAir", false)
							v.Parent:SetAttribute("InAir", false)
							print("Changed from air attack connection STIILL")
							airConnection:Disconnect()
						end
						end)
						end)
1 Like

Hard to tell the context of your code without the full script and poor formatting.

it’s not disconnecting because your if conditional statements aren’t being met. Print out the variables such as lastAirAttack, are they what you expect? There’s not much we can do to help debug your script.

1 Like

it’s printing “changed from air attack connection stiill”, yet it’s still not disconnecting, but i further debugged it so that after that, it would print airConnection.Connected and it printed false, but it keeps running?

1 Like

does it keep printing? or does it only print a few times then stop?

1 Like

it keeps printing over and over like i never disconnected it

1 Like

Why did you sandbox the whole thing in a pcall? That will only hide any errors. Can you remove the pcall and tell me if there are any errors?

1 Like

No errors after removing pcall