Is it necessary to disconnect a not use connection

Im wondering what if i dont disconnect a connection like this after player left

local Players = game:GetService("Players")
local MaxExp = 100

local function OnPlayerAdded(Player)
	
	local PlayerLevel = Player:WaitForChild("leaderstats")["🆙Level"]
	local PlayerExp = Player:WaitForChild("Experient")
	
	PlayerExp.Changed:Connect(function()
		if PlayerExp.Value == MaxExp then
			PlayerExp.Value = 0
			PlayerLevel.Value = PlayerLevel.Value + 1
		end
	end)
	
end



Players.PlayerAdded:Connect(OnPlayerAdded)

In this case no, because roblox will automatically GC the connection when the player leaves.

1 Like

To expand on that, the reason why you don’t need to disconnect is because the PlayerExp object is destroyed when the player leaves (because it’s inside the Player object, which is also destroyed, and thus everything in it is also destroyed). Any destroyed objects will automatically disconnect events attached to it.

1 Like