Why isn't this function (Touched) Disconnecting?

Hey,

I’m pretty new to scripting but heard Disconnecting is important in case of memory leaks,so i was wondering why this is still connected (At least the print said it was)

Script:

local attacked
hurt = true – Damage
for _, child in pairs(wep:GetChildren()) do
if child:IsA(“Part”) then
attacked = child.Touched:connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) ~= nil and hurt == true then
soundsclone.Hit:Play()
hit.Parent:FindFirstChild(“Humanoid”):TakeDamage(25)
hurt = false
Bleed:FireAllClients(hit)
if attacked ~= nil then attacked:Disconnect() print(attacked)

Thanks,

Simply printing the connection will not dictate if it’s connected or not as it will just print the datatype. You need to use the .Connected property:

local connection = workspace.ChildAdded:Connect(function()
	
end)

print(connection.Connected) --true
connection:Disconnect()
print(connection.Connected) --false

This will take care of the memory leaks for you, but if intended the variable to be nil, then just set it to nil.