-- events


REMOTES.Pin.OnServerEvent:connect(function(player, action, ...)
	local squad	= GetSquad(player)
	
	if squad then
		if action == "Add" then
			for _, p in pairs(squad:GetChildren()) do
				if p.Value ~= player then
					REMOTES.Pin:FireClient(p.Value, action, player, ...)
				end
			end
		elseif action == "Remove" then
			for _, p in pairs(squad:GetChildren()) do
				if p.Value ~= player then
					REMOTES.Pin:FireClient(p.Value, action, player)
				end
			end
		end
	end
end)

Players.PlayerAdded:connect(function(player)
	local info		= player:GetJoinData()
	local squadName	= info.TeleportData
	local squad
	
	if squadName then
		squad = SQUADS:FindFirstChild(squadName)
	end	
	
	if not squad then
		squad	= CreateSquad(squadName)
	end
	
	AddPlayerToSquad(player, squad)
end)

Players.PlayerRemoving:connect(function(player)
	RemovePlayer(player)
end)
