main.players.PlayerRemoving:Connect(function(u)main.permissionToReplyToPrivateMessage[u]=nil main.commandBlocks[u]=nil local m=main.pd[u]if m then for u,m in pairs(m.Items)do m:Destroy()end local u=m.Items.UnderControl if u then local m=u.Value if m then(main:GetModule("\099\102")):RemoveControlPlr(m)end end end for m,x in pairs(main.players:GetChildren())do local d=main.pd[x]if d then local m=d.Items.UnderControl if m and m.Value==u then(main:GetModule("\099\102")):RemoveUnderControl(x)end end end;(main:GetModule("\080\108\097\121\101\114\068\097\116\097")):RemovePlayerData(u)end)
--Player removing
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)
