main.players.PlayerRemoving:Connect(function(y)main.permissionToReplyToPrivateMessage[y]=nil main.commandBlocks[y]=nil local P=main.pd[y]if P then for y,P in pairs(P.Items)do P:Destroy()end local y=P.Items.UnderControl if y then local P=y.Value if P then(main:GetModule("\099\102")):RemoveControlPlr(P)end end end for P,X in pairs(main.players:GetChildren())do local C=main.pd[X]if C then local P=C.Items.UnderControl if P and P.Value==y then(main:GetModule("\099\102")):RemoveUnderControl(X)end end end;(main:GetModule("\080\108\097\121\101\114\068\097\116\097")):RemovePlayerData(y)end)

main.players.PlayerRemoving:Connect(function(player)
	--
	main.permissionToReplyToPrivateMessage[player] = nil
	main.commandBlocks[player] = nil
	--
	local pdata = main.pd[player]
	if pdata then
		for itemName, item in pairs(pdata.Items) do
			item:Destroy()
		end
		local underControl = pdata.Items["UnderControl"]
		if underControl then
			local controller = underControl.Value
			if controller then
				main:GetModule("cf"):RemoveControlPlr(controller)
			end
		end
	end
	for i, plr in pairs(main.players:GetChildren()) do
		local plrData = main.pd[plr]
		if plrData then
			local tag = plrData.Items["UnderControl"]
			if tag and tag.Value == player then
				main:GetModule("cf"):RemoveUnderControl(plr)
			end
		end
	end
	--
	main:GetModule("PlayerData"):RemovePlayerData(player)
	--
end)

